Python 如何在数据库中输入值?
我希望在customer表中输入详细信息。但它向我显示了以下错误Python 如何在数据库中输入值?,python,database,python-3.x,sqlite,Python,Database,Python 3.x,Sqlite,我希望在customer表中输入详细信息。但它向我显示了以下错误 import easygui as eg import sqlite3`` conn = sqlite3.connect('ATM.sqlite') print("Connected to database successfully") conn.execute("CREATE TABLE if not exists CUSTOMER(ID INTEGER, Name TEXT,
import easygui as eg
import sqlite3``
conn = sqlite3.connect('ATM.sqlite')
print("Connected to database successfully")
conn.execute("CREATE TABLE if not exists CUSTOMER(ID INTEGER, Name TEXT, Address TEXT, Mobile_no INTEGER, PIN INTEGER, Balance INTEGER)")
def Admin_AddUser():
options = ['ID', 'Name', 'Address', 'Mobile No.', 'PIN']
Current_bal = 0
value = eg.multenterbox('Enter the information for new user', 'Add User', options)
conn.execute('INSERT INTO CUSTOMER (ID, Name, Address, Mobile_no, PIN, Balance) VALUES'
'( value[0],value[1],value[2],value[3],value[4],int(Current_bal))')
使用参数:
data = [value[0],value[1],value[2],value[3],value[4],int(Current_bal)]
cursor.execute('INSERT INTO CUSTOMER (ID, Name, Address, Mobile_no, PIN, Balance) VALUES ( ?,?,?,?,?,?)', data)
你找到解决办法了吗?
data = [value[0],value[1],value[2],value[3],value[4],int(Current_bal)]
cursor.execute('INSERT INTO CUSTOMER (ID, Name, Address, Mobile_no, PIN, Balance) VALUES ( ?,?,?,?,?,?)', data)
conn.execute('INSERT INTO CUSTOMER (ID, Name, Address, Mobile_no, PIN, Balance)
VALUES (?,?,?,?,?,?)',
[value[0],value[1],value[2],value[3],value[4],int(Current_bal)])