使用Python QT和MySQL数据库将数据插入MySQL
我正在努力从我尝试的数据库中插入或检验数据,并观看了许多教程,但是每次停止cur.execute()
时。我发现问题在于self.firstnmae.text()funtion之类的值
def SignupFunction(self):
try:
connection = pymysql.connect(host=cr.host, user=cr.user, password=cr.password, database=cr.database)
cur = connection.cursor()
cur.execute("insert into users (FirstNmae , LastName, Email,Password , Confirm_Paswword ,Answer) value( %s, %s, %s, %s, %s, %s)",
(
self.FirstNmae.text(),
self.LastName.text(),
self.Email.text(),
self.Password.text(),
self.Confirm_Paswword.text(),
self.Answer.text()
))
connection.commit()
connection.close()
self.labelResult.setText("Data Inserted ")
except Exception as e:
self.labelResult.setText("Error Inserting Data")
I'm struggling to insert or retrive data from database I tried and I watched many tutorials but every time it stops in cur.execute()
. i found problem is in the value like self.FirstNmae.text() funtion stop here
def SignupFunction(self):
try:
connection = pymysql.connect(host=cr.host, user=cr.user, password=cr.password, database=cr.database)
cur = connection.cursor()
cur.execute("insert into users (FirstNmae , LastName, Email,Password , Confirm_Paswword ,Answer) value( %s, %s, %s, %s, %s, %s)",
(
self.FirstNmae.text(),
self.LastName.text(),
self.Email.text(),
self.Password.text(),
self.Confirm_Paswword.text(),
self.Answer.text()
))
connection.commit()
connection.close()
self.labelResult.setText("Data Inserted ")
except Exception as e:
self.labelResult.setText("Error Inserting Data")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你好朋友,我无法发表评论,所以我将作为您的代码中的答案发布,您是新开发人员,您的功能很好,我认为问题在您的数据库中,如果您是数据库,请查看数据库错过了一些东西,或者你写的属性像firstnmae
hello friend i'm not able to comment so i will post as answer from your code you are a new developer , your function is good there are no problem in it i think that the problem is in you database look at the database if you are missed something or you mess write attributes like FirstNmae