Exemplo n.º 1
0
 def exec_updsql(self, strsql):
     try:
         cur = self._conn.cursor()
         #strsql = "%s\ncommit;" % (strsql)
         strsql = "%s\n;" % (strsql)
         cur.execute(strsql)
         cur.close()
     except:
         cf.log(strsql)
         cur.close()
Exemplo n.º 2
0
 def exec_selsql(self, strsql):
     try:
         cur = self._conn.cursor()
         cur.execute(strsql)
         result = self.cur2arr(cur)
         cur.close()
         return result
     except:
         cf.log(strsql)
         cur.close()
Exemplo n.º 3
0
 def exec_updsql(self, strsql):
     try:
         cursor = self.conn.cursor()
         cursor.execute(strsql)
         cursor.close()
         self.conn.commit()
     except MySQLdb.Error, e:
         f.log(strsql)
         cursor.close()
         raise Exception("SQL ERROR %d: %s" % (e.args[0], e.args[1]))
Exemplo n.º 4
0
 def exec_selsql(self, strsql):
     try:
         cursor = self.conn.cursor()
         cursor.execute(strsql)
         result = self.cur2arr(cursor)
         cursor.close()
         return result
     except MySQLdb.Error, e:
         f.log(strsql)
         cursor.close()
         raise Exception("SQL ERROR %d: %s" % (e.args[0], e.args[1]))
Exemplo n.º 5
0
    def exec_selsqlh(self, strsql):
        try:
            cursor = self.conn.cursor()
            cursor.execute(strsql)
            body = map(list, list(cursor.fetchall()))
            desc = [d[0] for d in cursor.description]
            data = []
            header = {}
            i = 0
            for h in desc:
                header[h.lower()] = i
                i = i + 1
            data.append(header)
            data.append(body)
            cursor.close()
            return data

        except MySQLdb.Error, e:
            f.log(strsql)
            cursor.close()
            raise Exception("SQL ERROR %d: %s" % (e.args[0], e.args[1]))