示例#1
0
文件: db.py 项目: rsj217/dtapi-flask
 def wrap(*args):
     try:
         db = pool.connection()
         cursor = db.cursor()
         sql = func(*args)
         cursor.callproc(*sql)
         result = cursor.fetchall()
         rownum = cursor.rowcount
         return (rownum, result)
     except mysql.Error, e:
         print "Mysql Error %d: %s" % (e.args[0], e.args[1])
示例#2
0
文件: db.py 项目: rsj217/dtapi-flask
 def wrap(*args):
     try:
         db = pool.connection()
         cursor = db.cursor()
         sql = func(*args)
         rownum = cursor.execute(sql)
         result = None
         if rownum > 0:
             result = cursor.fetchall()
         return (rownum, result)
     except mysql.Error, e:
         print "Mysql Error %d: %s" % (e.args[0], e.args[1])
示例#3
0
文件: db.py 项目: rsj217/dtapi-flask
 def wrap(*args):
     try:
         #: 连接数据库
         db = pool.connection()
         #: 获取数据查询游标
         cursor = db.cursor()
         #: 得到 sql 语句
         sql = func(*args)
         #: 执行单条 sql 语句, 返回受影响的行数
         rownum = cursor.execute(sql)
         result = None
         if rownum > 0:
             #: 执行查询,返回单条数据
             result = cursor.fetchone()
             #: 返回查询结果和影响行数
         return (rownum, result)
     except mysql.Error, e:
         print "Mysql Error %d: %s" % (e.args[0], e.args[1])
示例#4
0
文件: db.py 项目: rsj217/dtapi-flask
 def wrap(*args):
     try:
         #: 连接数据库
         db = pool.connection()
         #: 获取数据查询游标
         cursor = db.cursor()
         #: 得到 sql 语句
         sql = func(*args)
         #: 执行单条 sql 语句, 返回受影响的行数
         rownum = cursor.execute(sql)
         #: 提交查询
         db.commit()
         #: 返回影响行数
         return rownum
     except mysql.Error, e:
         #: 发生错误时回滚
         db.rollback()
         print "Mysql Error %d: %s" % (e.args[0], e.args[1])