1、MySQL-python (MySQLdb)
MySQL-python 又叫 MySQLdb,是 Python 连接 MySQL 最流行的一个驱动,很多框架都也是基于此库进行开发,遗憾的是它只支持...在python中简单的使用
1、连接数据库
db = MySQLdb.connect('127.0.0.1','root','root','database')
#或者
db = MySQLdb.connect...Plate", 0, 4, 3, 5.95 )
] )
完整示例:
# coding=utf-8
import MySQLdb
# 打开数据库连接
db = MySQLdb.connect...,(cid,cid))
# 执行sql语句,查
cursor.execute(sql_sel,(cid,))
data = cursor.fetchall()
# 提交到数据库执行...db.commit()
except:
# 发生错误时回滚
db.rollback()
# 关闭数据库连接
db.close()