基本上我试图将数据插入数据库,然后在其他地方读取数据并将每个单独的部分插入到输入字段中。
首先,这是我希望从Statistics page
将数据插入数据库的页面在此页面中,我希望将占用,每月租赁,估计属性值全部存储在名为“PropertyStatistics”which is showed here
的数据库中保存后,我希望将存储的值输出到输入框中,以便显示
当前代码 我用于将数据插入数据库的代码:
def data_entry():
OccupationA = str(Statusvar.get())
MonthlyRentalA = RentalmoneyUpdated
EstimatedPropertyValueA = EstimatedValueentry
PropertyStatisticsR = c.fetchall()
for column in PropertyStatisticsR:
ID = column[1]
OccupationA = column[2]
MonthlyRentalA = column[3]
EstimatedPropertyValueA = column[4]
c.execute("INSERT INTO PropertyStatistics(ID,Occupation,Monthly Rental,Estimated Property Value) VALUES (%s, %s, %s, %s)",
(ID,OccupationA,MonthlyRentalA,EstimatedPropertyValueA))
conn.commit()
time.sleep(1)
函数“data_entry”由“save”按钮调用,如link1所示 目前对于此代码,执行此功能时没有出现任何错误,但是没有任何内容保存到数据库中,这意味着我忽略了错误
我是初学者,任何帮助都会受到赞赏,因为我之前没有做过这类事。
我不希望回复包含此工作所需的所有代码。我只需要一个方向,从现在的位置去哪里
答案 0 :(得分:2)
对于多字列名,在引用时,它们应该包含在``。
中INSERT INTO PropertyStatistics(ID,Occupation,`Monthly Rental`,`Estimated Property Value`) VALUES (%s, %s, %s, %s)