wip
This commit is contained in:
parent
42f2a718ec
commit
8f8fdd22e5
1 changed files with 4 additions and 4 deletions
|
@ -15,18 +15,18 @@ def db():
|
||||||
|
|
||||||
return g.db_connection
|
return g.db_connection
|
||||||
|
|
||||||
def query(query, **params):
|
def query(querystring, **params):
|
||||||
try:
|
try:
|
||||||
cursor = db().cursor()
|
cursor = db().cursor()
|
||||||
cursor.paramstyle = "named"
|
cursor.paramstyle = "named"
|
||||||
cursor.execute(query, params)
|
cursor.execute(querystring, params)
|
||||||
db().commit()
|
db().commit()
|
||||||
return cursor
|
return cursor
|
||||||
except:
|
except:
|
||||||
db().rollback()
|
db().rollback()
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def select(query, **params):
|
def select(querystring, **params):
|
||||||
cursor = query(query, **params)
|
cursor = query(querystring, **params)
|
||||||
columns = [x[0] for x in cursor.description]
|
columns = [x[0] for x in cursor.description]
|
||||||
return [dict(zip(columns, row)) for row in cursor.fetchall()]
|
return [dict(zip(columns, row)) for row in cursor.fetchall()]
|
||||||
|
|
Loading…
Reference in a new issue