mysqlsqlpython数据库
GAME_ID = s["resultSets"][0]["rowSet"][i][0]
TEAM_ID = s["resultSets"][0]["rowSet"][i][1]
PLAYER_NAME = s["resultSets"][0]["rowSet"][i][5]
db = MySQLdb.connect("localhost","root","199536abc","test")
cursor = db.cursor()
sql = """INSERT INTO PLAYER(GAME_ID,TEAM_ID,NAME)
VALUES (GAME_ID,TEAM_ID,PLAYER_NAME)"""
try:
# 执行sql语句
cursor.execute(sql)
# 提交到数据库执行
db.commit()
except:
# Rollback in case there is any error
db.rollback()
1 |
|