Exemplo n.º 1
0
def connect():
    conn = psycopg2.connect('', connection_factory=psycopg2.extras.LoggingConnection)

    conn.initialize(logging.root)

    conn.commit = log_call_basic(conn.commit)
    conn.rollback = log_call_basic(conn.rollback)

    return conn
Exemplo n.º 2
0
 def decorated(*args, **kwargs):
     with closing(connect()) as conn:
         conn.commit = log_call_basic(conn.commit)
         conn.rollback = log_call_basic(conn.rollback)
         return f(conn, *args, **kwargs)