請我是 python 和 sqlite3 的新手,我試圖找到注冊表單無法提交的可能原因,它一直給我一個錯誤。并且提供的值不斷倒計時c.execute("INSERT INTO users VALUES (?, ?, ?, ?, ?, ?)", (element)) sqlite3.OperationalError:表 users 有 7 列,但提供了 6 個值 # Importing Tkinter framework fr om tkinter import * from tkinter import ttk # Import sqlite3 import sqlite3 def setup_db(): # Open db global conn conn = sqlite3.connect('shengen.db') # Create a cursor global c c = conn.cursor() # Create the table if it doesn't exist try: c.execute("""CREATE TABLE if not exists users( ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, fname TEXT NOT NULL, email TEXT NOT NULL, password TEXT NOT NULL, cPassword TEXT NOT NULL, sex INTEGER NOT NULL, country TEXT NOT NULL );""") conn.commit() except sqlite3.OperationalError: print("ERROR: Table not Created") def reg_submit(): # Insert record into the db new_user = [fname.get(), email.get(), password.get(), cPassword.get(), sex.get(), country.get()] for element in new_user: c.execute("INSERT INTO users VALUES (?, ?, ?, ?, ?, ?)", (element)) conn.commit() c.close() conn.close() def register(): root1 = Toplevel(root) root1.geometry("900x700") root1.title("Registration Page") root1.iconbitmap("") global fname global email global password global cPassword global sex global sex1 global country
Sqlite3 表 users 有 7 列,但提供了 6 個值
12345678_0001
2023-06-27 13:47:46