Commit d173fa12 authored by Vladislav Rykov's avatar Vladislav Rykov
Browse files

pend dao changed

parent 255d4e9b
import psycopg2 from misc import with_psql
# decorator implementation
def with_psql(f):
def _with_psql(*args, **kwargs):
conn = psycopg2.connect('dbname=gateway')
cur = conn.cursor()
try:
res = f(cur, *args, **kwargs)
except (Exception, psycopg2.DatabaseError) as error:
conn.rollback()
res = (False, error)
else:
conn.commit()
finally:
cur.close()
conn.close()
return res
return _with_psql
@with_psql @with_psql
def create(cur, appkey, devid, msg): def create(cur, appkey, devid, msg):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment