python pymysql 数据库查询操作

import pymysql


db= pymysql.connect(host="", user=‘‘, database="",
                        password=‘‘)
cursor = db.cursor(cursor=pymysql.cursors.DictCursor)
cursor.execute("SELECT order_no FROM table  limit 10")
order_stat= cursor.fetchall()
print(order_stat)
cursor.close()
db.close()


‘‘‘
###简写
cursor = pymysql.connect(host="", user=‘‘, database="",
                        password=‘‘, cursorclass=pymysql.cursors.DictCursor).cursor()
cursor.execute("SELECT order_no FROM table limit 10")

# order_stat = cursor.fetchall()
order_stat = cursor.fetchone()
print(order_stat)
cursor.close()
‘‘‘

  

python pymysql 数据库查询操作

上一篇:pgsql pldebugger插件


下一篇:Jquery 验证注册