Python 对mysql数据库的操作
#!.../usr/bin/python
# -*- coding: utf-8 -*-
import MySQLdb
class mysql:
def __init__(self, sql, host...where id=3')
conn.commit()
cur.close()
conn.close()
except MySQLdb.Error, e:
print "Mysql... Error %d: %s" % (e.args[0], e.args[1])
常用函数:
然后,这个连接对象也提供了对事务操作的支持,标准的方法
commit()提交
rollback()回滚
cursor...):执行单条sql语句,接收的参数为sql语句本身和使用的参数列表,返回值为受影响的行数
executemany(self, query, args):执行单挑sql语句,但是重复执行参数列表里的参数,