Skip to content
Snippets Groups Projects
Commit 330b744c authored by Simon Künzel's avatar Simon Künzel
Browse files

Change psycopg version from 3 to 2

parent ca91307f
No related branches found
No related tags found
No related merge requests found
...@@ -91,11 +91,11 @@ elif config['DB_ENGINE'] == 'mysql': ...@@ -91,11 +91,11 @@ elif config['DB_ENGINE'] == 'mysql':
db.close() db.close()
return res return res
elif config['DB_ENGINE'] == 'postgres': elif config['DB_ENGINE'] == 'postgres':
import psycopg # pylint: disable=import-error import psycopg2 # pylint: disable=import-error
def get_dbcursor(): def get_dbcursor():
if 'db' not in g or g.db.broken: if 'db' not in g or g.db.closed:
g.db = psycopg.Connection.connect( g.db = psycopg2.connect(
host=config["POSTGRES_HOST"], host=config["POSTGRES_HOST"],
port=config["POSTGRES_PORT"], port=config["POSTGRES_PORT"],
user=config["POSTGRES_USER"], user=config["POSTGRES_USER"],
...@@ -133,7 +133,7 @@ def query(operation, *params, delim="sep", nlfix=True): ...@@ -133,7 +133,7 @@ def query(operation, *params, delim="sep", nlfix=True):
try: try:
rows = cur.fetchall() rows = cur.fetchall()
except Exception as e: # pylint: disable=broad-except except Exception as e: # pylint: disable=broad-except
if str(e) == 'No result set to fetch from.' or str(e) == "the last operation didn't produce a result": if str(e) == 'no results to fetch' or str(e) == "the last operation didn't produce a result":
# no problem, we were just at the end of the result set # no problem, we were just at the end of the result set
pass pass
else: else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment