wip
This commit is contained in:
parent
7b9e91acd0
commit
eefd4272ff
1 changed files with 2 additions and 9 deletions
|
@ -4,8 +4,6 @@ import pg8000
|
|||
|
||||
from flask import g
|
||||
|
||||
DBResult = namedtuple('Result', 'rows rowcount')
|
||||
|
||||
def db():
|
||||
if not hasattr(g, 'db_connection'):
|
||||
g.db_connection = pg8000.connect(
|
||||
|
@ -23,13 +21,8 @@ def query(query, **params):
|
|||
cursor.execute(query, params)
|
||||
db().commit()
|
||||
|
||||
if cursor._cached_rows:
|
||||
columns = [x[0] for x in cursor.description]
|
||||
rows = [dict(zip(columns, row)) for row in cursor.fetchall()]
|
||||
# rdef = namedtuple('row', ' '.join([x[0] for x in cursor.description]))
|
||||
# rows = list(map(rdef._make, cursor.fetchall()))
|
||||
else:
|
||||
rows = []
|
||||
columns = [x[0] for x in cursor.description]
|
||||
rows = [dict(zip(columns, row)) for row in cursor.fetchall()]
|
||||
|
||||
return DBResult(
|
||||
rows=rows,
|
||||
|
|
Loading…
Reference in a new issue