Exemplo n.º 1
0
 def execute_update(self, query):
     logger.info('query:%s' % query)
     try:
         db_cursor = self.dbconn.cursor()
         db_cursor.execute(query)
         db_cursor.execute('commit')
         return True
     except Exception as e:
         logger.error('执行数据库更新操作失败:%s' % e)
         db_cursor.execute('rollback')
         db_cursor.close()
         exit()
Exemplo n.º 2
0
 def execute_insert(self, query, data):
     logger.info('query:%s  data:%s' % (query, data))
     try:
         db_cursor = self.dbconn.cursor()
         db_cursor.execute(query, data)
         db_cursor.execute('commit')
         return True
     except Exception as e:
         logger.error('执行数据库插入操作失败:%s' % e)
         db_cursor.execute('rollback')
         db_cursor.close()
         exit()
Exemplo n.º 3
0
 def select_many_record(self, query, data=""):
     '''返回结果只包含多条记录'''
     logger.info('query:%s  data:%s' % (query, data))
     try:
         db_cursor = self.dbconn.cursor()
         if data:
             db_cursor.execute(query, data)
         else:
             db_cursor.execute(query)
         query_result = db_cursor.fetchall()
         return query_result
     except Exception as e:
         logger.error('执行数据库查询操作失败:%s' % e)
         db_cursor.close()
         exit()