import sqlite3
def create_a_new_table():
Myschool = sqlite3.connect('normal database for experiment purpose.db')
curschool = Myschool.cursor()
curschool.execute("""
CREATE TABLE new_Basic_Player_Info
(
Ranking INTEGER,
Player_name TEXT,
Country TEXT,
Speciality TEXT,
Value INTEGER,
Cost INTEGER
);
""")
Myschool.close()
def insert_data():
Myschool = sqlite3.connect('normal database for experiment for purpose.db')
curschool = Myschool.cursor()
# nm = input("Enter the name of the player: ")
sql = """INSERT INTO TABLE new_Basic_Player_Info(Ranking, Player_name)
VALUES(%s, %s);"""
可能是%s,%s是问题所在。或者,sql命名字符串应以分号(;)结尾,表示未执行的主代码
try:
curschool.execute(sql, (1, "aNIKET GHOSH"))
Myschool.commit()
Myschool.close()
except:
Myschool.rollback()
甚至我也用过try和except关键字。
create_a_new_table()
insert_data()
https://stackoverflow.com/questions/51004938
复制相似问题