【问题标题】:attribute error that i cant understand the reason for我无法理解原因的属性错误
【发布时间】:2020-11-15 01:27:41
【问题描述】:

这是我的代码。我是新来的。有人请帮助解决这个错误。

def database(self):
    don = mdb.connect('localhost', 'root', '', 'project')
    with don:
        cur = don.cursor()

        cur.execute("INSERT INTO p1(name, age)"
                    "VALUES('%s', '%s')" % (''.join(self.lineEdit_2.text()),
                                            ''.join(self.lineEdit_3.text())))

        QMessageBox.about(self, 'Connection', 'Data Inserted Successfully')
        self.close()

错误: 与唐: 属性错误:输入

【问题讨论】:

  • 你在你的代码中使用了哪些mysql python模块?
  • 我正在使用 pymysql,mysqlclient

标签: mysql pyqt5 attributeerror pymysql mysql-connector-python


【解决方案1】:
def database(self):
  don = mdb.connect('localhost', 'root', '', 'project')

  with don.cursor() as cur:
      cur.execute("INSERT INTO p1(name, age)"
                "VALUES('%s', '%s')" % (''.join(self.lineEdit_2.text()),
                                        ''.join(self.lineEdit_3.text())))

      QMessageBox.about(self, 'Connection', 'Data Inserted Successfully')
       self.close()

【讨论】:

  • 感谢您的帮助。现在它说数据已插入并且没有属性错误,但是当我查看 phpmyadmin 时它显示没有条目。
  • cur.execute("INSERT INTO p1 (name, age) VALUES('stack',20)") don.commit() 试试这个@mmm 如果这可行,你需要检查你的 join 语句
  • 这产生了相同的结果:with con: AttributeError: enter
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-10-05
  • 2022-10-14
  • 2015-05-09
  • 2023-03-17
  • 1970-01-01
  • 2013-11-22
  • 1970-01-01
相关资源
最近更新 更多