python 操作MySQL指南
2014-03-16 20:07
375 查看
1. python 安装 MySQLdb 模块 对MySQl进行操作
创建MySQL连接
conn = MySQLdb.connect(host="", user="", passwd="", db="", charset="utf8") // 创建连接
cursor = conn.cursor() // 创建指针
# insert
sql = "insert into tableName values (%s, %s)"
param = ('one', 'two')
cursor.execute(sql, param)
conn.commit() // 一定要commit 否则会很郁闷的 数据库里的id会自增 但不会有数据 作者就遇到过此问题 @_@~
创建MySQL连接
conn = MySQLdb.connect(host="", user="", passwd="", db="", charset="utf8") // 创建连接
cursor = conn.cursor() // 创建指针
# insert
sql = "insert into tableName values (%s, %s)"
param = ('one', 'two')
cursor.execute(sql, param)
conn.commit() // 一定要commit 否则会很郁闷的 数据库里的id会自增 但不会有数据 作者就遇到过此问题 @_@~
相关文章推荐
- Python操作MySQL
- python操作MySQL 模拟简单银行转账操作
- python关于Mysql操作
- python 如何操作mysql 数据库
- MySQLdb的使用 Python操作Mysql
- Python操作MySQL
- python 操作mysql 详解
- Python操作MySQL以及中文乱码的问题_mengl_2011-ChinaUnix博客
- Python操作Mysql
- python 3.3 mySql 操作
- python对于Mongo数转存到Mysql的操作
- Python开发【第十九篇】:Python操作MySQL
- Python操作mysql之查询数据
- [置顶] 【python mysql】数据库 使用Python操作MySQL
- python操作MongoDB、MySQL、Postgres、Sqlite、redis实例
- python2.0_s12_day9_mysql操作
- Python 操作MySQL详解及实例
- python with statement 进行文件操作指南
- Python学习笔记——MySQL的基本操作(2)
- 用python简单实现类似thinkphp的针对Mysql操作的数据模型