mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-18 01:50:32 +03:00
Get CockroachDB version from the connection info
This commit is contained in:
parent
7e1e801899
commit
9380f2a721
|
@ -424,13 +424,10 @@ def crdb_version(conn, __crdb_version=[]):
|
||||||
if __crdb_version:
|
if __crdb_version:
|
||||||
return __crdb_version[0]
|
return __crdb_version[0]
|
||||||
|
|
||||||
with conn.cursor() as cur:
|
sver = conn.info.parameter_status("crdb_version")
|
||||||
try:
|
if sver is None:
|
||||||
cur.execute("show crdb_version")
|
|
||||||
except psycopg2.ProgrammingError:
|
|
||||||
__crdb_version.append(None)
|
__crdb_version.append(None)
|
||||||
else:
|
else:
|
||||||
sver = cur.fetchone()[0]
|
|
||||||
m = re.search(r"\bv(\d+)\.(\d+)\.(\d+)", sver)
|
m = re.search(r"\bv(\d+)\.(\d+)\.(\d+)", sver)
|
||||||
if not m:
|
if not m:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user