From: Daniele Varrazzo Date: Sat, 14 Mar 2020 11:59:36 +0000 (+1300) Subject: Added PGconn.protocol_version X-Git-Tag: 3.0.dev0~721 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4eef2d81b6bb12bd7e8d24bc26b07e724c14ba68;p=thirdparty%2Fpsycopg.git Added PGconn.protocol_version --- diff --git a/psycopg3/_pq_ctypes.py b/psycopg3/_pq_ctypes.py index 1feb246ac..da779cf40 100644 --- a/psycopg3/_pq_ctypes.py +++ b/psycopg3/_pq_ctypes.py @@ -141,6 +141,10 @@ PQparameterStatus = pq.PQparameterStatus PQparameterStatus.argtypes = [PGconn_ptr, c_char_p] PQparameterStatus.restype = c_char_p +PQprotocolVersion = pq.PQprotocolVersion +PQprotocolVersion.argtypes = [PGconn_ptr] +PQprotocolVersion.restype = c_int + PQerrorMessage = pq.PQerrorMessage PQerrorMessage.argtypes = [PGconn_ptr] PQerrorMessage.restype = c_char_p diff --git a/psycopg3/pq_ctypes.py b/psycopg3/pq_ctypes.py index 88c873f42..f7d3a42f3 100644 --- a/psycopg3/pq_ctypes.py +++ b/psycopg3/pq_ctypes.py @@ -173,6 +173,10 @@ class PGconn: rv = impl.PQparameterStatus(self.pgconn_ptr, self._encode(name)) return self._decode(rv) + @property + def protocol_version(self): + return impl.PQprotocolVersion(self.pgconn_ptr) + @property def error_message(self): return self._decode(impl.PQerrorMessage(self.pgconn_ptr)) diff --git a/tests/test_pq.py b/tests/test_pq.py index 5f1c22a8e..5e02b5403 100644 --- a/tests/test_pq.py +++ b/tests/test_pq.py @@ -179,3 +179,7 @@ def test_parameter_status(pq, dsn, tempenv): pgconn = pq.PGconn.connect(dsn) assert pgconn.parameter_status('application_name') == "psycopg3 tests" assert pgconn.parameter_status('wat') is None + + +def test_protocol_version(pgconn): + assert pgconn.protocol_version == 3