Commit 255d4e9b authored by Vladislav Rykov's avatar Vladislav Rykov
Browse files

data dao changed

parent 1067f8e8
import psycopg2
from psycopg2 import sql from psycopg2 import sql
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
......
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