在我的项目中,我正在使用Tkinter和Sqlite3创建一个Login and Registration表单,我在Query中遇到错误。
def database():
name1 = Fullname.get()
email = Email.get()
passData = Password.get()
gender = var.get()
country = c.get()
prog = var1.get()
conn = sqlite3.connect('Form.db')
with conn:
cursor = conn.cursor()
cursor.execute(
'CREATE TABLE IF NOT EXISTS Student (Fullname TEXT,Email TEXT,Password TEXT ,Gender TEXT,country TEXT,Programming TEXT)')
cursor.execute('INSERT INTO Student (FullName,Email,Password,Gender,country,Programming ) VALUES(?,?,?,?,?,?)',
(name1, email, passData, gender, country, prog))
conn.commit()
错误消息:
File "C:/Users/JMD1/PycharmProjects/BugFreeRam/registrationFor.py", line 44, in database (name1, email, passData, gender, country, prog)) sqlite3.OperationalError: table Student has no column named Password
答案 0 :(得分:1)
由于使用CREATE TABLE IF NOT EXISTS
,因此出现错误。这意味着您之前已经创建了Student
表,而没有Password
列。
首先拖放Student
表,然后重新创建它。
另一个选择是更改表以添加Password
列。
cursor.execute("alter table student add column 'password' 'text'")