社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

Python SQlite3更新无错误,但不更新

Marcus • 3 年前 • 1183 次点击  

它没有显示错误,可以运行,但SQLite表中的数据不会更新。然而,其他更新功能类似于这项工作

def seller_edit():
    while True:
        sellername = str(input("Enter your username: "))
        with sqlite3.connect(r"C:\Users\User\Desktop\HFSystem\Assginment\HFuserinfo.db") as connect:
            cursor = connect.cursor()
        check = "SELECT * FROM sellerinfo WHERE Username = ?"
        cursor.execute(check,[sellername])

        results = cursor.fetchall()

        if results:
            Phone = int(input("Enter New Phone No.: "))      
            Email = str(input("Enter New Email: "))
            Address = str(input("Enter New Address: "))
      

            updateseller ="""UPDATE sellerinfo SET Phone = ?, Email=?,Address=? WHERE Username=?"""
            
            cursor.execute(updateseller,[sellername,Phone,Email,Address])       
            connect.commit()
            print("Seller Info Edited!")
            connect.close()
            seller_info_menu()
            break

        else:
            print("ProductID does not recognised")
            option = input("Do you want to try again (y/n): ")
            if option.lower() == "n":
                seller_info_menu()
                break
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/128816
 
1183 次点击  
文章 [ 1 ]  |  最新文章 3 年前