Get CockroachDB version from the connection info

This commit is contained in:
Daniele Varrazzo 2020-07-21 21:48:11 +01:00
parent 7e1e801899
commit 9380f2a721

View File

@ -424,13 +424,10 @@ def crdb_version(conn, __crdb_version=[]):
if __crdb_version:
return __crdb_version[0]
with conn.cursor() as cur:
try:
cur.execute("show crdb_version")
except psycopg2.ProgrammingError:
sver = conn.info.parameter_status("crdb_version")
if sver is None:
__crdb_version.append(None)
else:
sver = cur.fetchone()[0]
m = re.search(r"\bv(\d+)\.(\d+)\.(\d+)", sver)
if not m:
raise ValueError(