Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Python和SQLite3创建更新记录函数_Python_Database_Sqlite_Tkinter - Fatal编程技术网

使用Python和SQLite3创建更新记录函数

使用Python和SQLite3创建更新记录函数,python,database,sqlite,tkinter,Python,Database,Sqlite,Tkinter,我目前正在为学校做一个课程项目,它是一个数据库系统,带有使用Tkinter、Python和SQLite3的用户界面。我已经做了一个表单来添加、删除、更新和搜索客户。update函数没有产生任何错误,但是没有对.db文件进行更改。谁能看一下,告诉我哪里出了问题?我将附上用户界面的照片和功能代码。我不习惯使用StackOverflow,所以如果我遗漏了什么或者您需要更多信息,请告诉我。先谢谢你 def UpdateCustomer(self): customerid = se

我目前正在为学校做一个课程项目,它是一个数据库系统,带有使用Tkinter、Python和SQLite3的用户界面。我已经做了一个表单来添加、删除、更新和搜索客户。update函数没有产生任何错误,但是没有对.db文件进行更改。谁能看一下,告诉我哪里出了问题?我将附上用户界面的照片和功能代码。我不习惯使用StackOverflow,所以如果我遗漏了什么或者您需要更多信息,请告诉我。先谢谢你

    def UpdateCustomer(self):
        customerid = self.CustomerEntry.get();
        town = self.TownEntry.get();
        postcode = self.PostcodeEntry.get();
        with sqlite3.connect("LeeOpt.db") as db:
            cursor = db.cursor()
            update_customer = ('''UPDATE Customer 
            SET 
            Town = ?,
            Postcode = ?
            WHERE CustomerID = ?
            ''')
            db.commit()

            cursor.execute(update_customer,[(customerid),(town),(postcode)])
            tkinter.messagebox.showinfo("Notification","Customer record updated successfully")
            self.ClearEntries()


必须传递将替换的参数值?placeholder的顺序与sql语句中的顺序完全相同:

cursor.execute(update_customer, (town, postcode, customerid))

必须传递将替换的参数值?placeholder的顺序与sql语句中的顺序完全相同:

cursor.execute(update_customer, (town, postcode, customerid))