[Python] How to find server_version in psycopg3?

Discussão em 'Python' iniciado por Stack, Março 13, 2025.

  1. Stack

    Stack Membro Participativo

    I have this test in Django [1] which is using psycopg2:

    from django.db import connection

    def test_postgresql_version(self):
    postgresql_version = connection.cursor().connection.server_version
    if (postgresql_version >= 140000):
    pass
    else:
    raise NotImplementedError("postgresql version must be at least 14.0.")


    This test fails with psycopg3:

    AttributeError: 'Connection' object has no attribute 'server_version'


    How do I check the server_version in psycopg3?

    Continue reading...

Compartilhe esta Página