PyQt5: chapter9-更新数据库表-更改用户密码

实例

  1. 创建基于Dialog without Buttons模板窗口
  2. 添加五个Label,四个LineEdit,一个PushButton部件
  3. 设定前四个Label的text为Email Address, Old Password, New Password, Re-enter New Password
  4. 设定第五个Label的text为空
  5. 设定PushButton的text为Change Password
  6. 设定Line Edit的objectName为lineEditEmailAddress, lineEditOldPassword, lineEditNewPassword, lineEditRePassword
  7. 设定PushButton的objectName为pushButtonChangePassword
  8. 设定第五个Label的object Name为labelResponse
  9. 保存为demoChangePassword.ui
  10. 使用pyuic生成demoChangePassword.py
  11. 创建callChangePassword.py,代码如下
import sqlite3, sys
from PyQt5.QtWidgets import QDialog, QApplication
from sqlite3 import Error
from cookbook_200504.demoSignInForm import *

class MyForm(QDialog):
    def __init__(self):
        super().__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.ui.pushButtonSearch.clicked.connect(self.SearchRows)
        self.show()
    def SearchRows(self):
        sqlStatement="SELECT EmailAddress, Password FROM Users where EmailAddress like'"+self.ui.lineEditEmailAddress.text()+"'and Password like '"+ self.ui.lineEditPassword.text()+"'"
        try:
            conn = sqlite3.connect("ECommerce.db")
            cur = conn.cursor()
            cur.execute(sqlStatement)
            row = cur.fetchone()
            if row==None:
                self.ui.labelResponse.setText("Sorry, Incorrect email address or password ")
            else:
                self.ui.labelResponse.setText("You are welcome ")
        except Error as e:
            self.ui.labelResponse.setText("Error in accessing row")
        finally:
            conn.close()
if __name__=="__main__":
    app = QApplication(sys.argv)
    w = MyForm()
    w.show()
    sys.exit(app.exec())

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值