数据库新手,我遇到了这个错误.我该怎么解决



c.execute("插入地址值(:f_name,:L_name,:address,:city,:state,:zipcode(";,sqlite3.OperationalError:没有这样的表:地址

我正在努力学习教程。目前我被困在这里。

def submit():
# clear the text boxes
conn = sqlite3.connect('address_book.db')
# create cursor
c = conn.cursor()
# insert to a table
c.execute("INSERT INTO addresses VALUES (:f_name, :L_name, :address, :city, :state, :zipcode)",
{
'f_name': f_name.get(),
'l_name': l_name.get(),
'address': address.get(),
'city': city.get(),
'state': state.get(),
'zipcode': zipcode.get()
})

conn.commit()
# close Connection
conn.close()

看起来您正试图插入到addresses表中。

错误no such table: addresses表示此表不存在。

在插入表之前,您首先需要创建表。例如:

CREATE TABLE addresses ( column1 datatype, column2 datatype, column3 datatype, .... );

或者检查您创建的原始表是否拼写错误。

最新更新