示例#1
0
 def execute(self, sql, params=[]):
     """
     Executes the given SQL statement, with optional parameters.
     """
     #print("schema:", sql)
     # Log the command we're running, then run it
     logger.debug("%s; (params %r)" % (sql, params))
     if self.collect_sql:
         self.collected_sql.append((sql % tuple(map(self.quote_value, params))) + ";")
     else:
         with self.connection.cursor() as cursor:
             cursor.execute(sql, params)
示例#2
0
 def execute(self, sql, params=[], has_result=False):
     """
     Executes the given SQL statement, with optional parameters.
     """
     result = None
     # Log the command we're running, then run it
     logger.debug("%s; (params %r)" % (sql, params))
     if self.collect_sql:
         self.collected_sql.append((sql % tuple(map(self.quote_value, params))) + ";")
     else:
         with self.connection.cursor() as cursor:
             cursor.execute(sql, params)
             if has_result:
                 result = cursor.fetchone()
     return result