Example #1
0
 def run(self, url_or_engine, conn_=None):
     """Run the contents of this SqlLog on a database"""
     engine = url_or_engine
     if type(url_or_engine) is str:
         engine = create_engine(url_or_engine)
     conn = conn_
     if conn_ is None:
         conn = engine.contextual_connect()
     try:
         for entry in self.entries:
             try:
                 conn._execute_raw(entry.statement, entry.parameters)
             except sqlalchemy.exceptions.SQLError, e:
                 # SQL error: add the original traceback to the message
                 raise exceptions.LogSqlError(e, entry)
     finally:
         if conn_ is None:
             # connection was made here - clean up
             conn.close()
Example #2
0
 def run(self,url_or_engine,conn_=None):
     """Run the contents of this SqlLog on a database"""
     engine=url_or_engine
     if type(url_or_engine) is str:
         engine=create_engine(url_or_engine)
     conn=conn_
     if conn_ is None:
         conn=engine.contextual_connect()
     try:
         for entry in self.entries:
             try:
                 conn._execute_raw(entry.statement,entry.parameters)
             except sqlalchemy.exceptions.SQLError,e:
                 # SQL error: add the original traceback to the message
                 raise exceptions.LogSqlError(e,entry)
     finally:
         if conn_ is None:
             # connection was made here - clean up
             conn.close()
Example #3
0
 def __connection(self, engine, **kwargs):
     if self.transaction is not None:
         return self.transaction.get_or_add(engine)
     else:
         return engine.contextual_connect(**kwargs)
Example #4
0
File: session.py Project: serah/HR
 def __connection(self, engine, **kwargs):
     if self.transaction is not None:
         return self.transaction.get_or_add(engine)
     else:
         return engine.contextual_connect(**kwargs)