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()
我也试过关键字:create_a_new_table()
insert_data()