我刚刚开始在python中使用MySQLdb。我可以创建表,但当我尝试插入时,没有行插入到表中,并且它显示表仍然是空的。
import MySQLdb
db = MySQLdb.connect("localhost","root","shivam","test")
cursor = db.cursor()
s = "DROP TABLE IF EXISTS batting"
cursor.execute(s)
s = """create table batting (
name varchar(50) primary key,
matches integer(5),
innings integer(5),
runs integer(5),
highest integer(3),
strikerate integer(3),
hundreds integer(3),
fifties integer(3)
)"""
cursor.execute(s)
s = """insert into batting(name) values(
"shivam")"""
cursor.execute(s)
db.close()我可能会出错的地方吗?
发布于 2015-09-03 19:15:40
https://stackoverflow.com/questions/32374077
复制相似问题