我正在编写一个程序来存储信用卡值作为练习。 我不断收到错误“ sqlite3.OperationalError:没有这样的列: 将创建该表,然后创建一列:名称。 列名称存在于SQLiteStudio中cc.db的cards表中 任何帮助表示赞赏。
import sqlite3
conn = sqlite3.connect('cc.db')
c = conn.cursor()
def createtaBLE():
c.execute("""CREATE TABLE IF NOT EXISTS cards (
name text,ccnumber integer,exp_date text,csv integer
)""")
conn.commit()
print('table created')
def entercard():
ccname = input('Enter the name of the new card: ')
ccnumber = input('Enter the card number: ')
ccexp_date = input('Enter the Expiration date: ')
cccsv = input('Enter the CSV number from the back of the card: ')
c.execute("INSERT INTO cards VALUES (?,?,?),(name,ccnumber,exp_date,csv)");
conn.commit()
def printall():
for card in c.execute('SELECT * FROM cards'):
print(card)
createtaBLE()
entercard()
printall()
conn.close()