if target == "online":
title = self.online_title_edit.text()
date = self.online_date_edit.date()
time = self.online_time_edit.time()
details = self.online_details_edit.toPlainText()
if title == "":
QMessageBox.information(self, "Hey!", "Fill in the blanks first!", QMessageBox.Ok)
else:
con = mysql.connect(host="89.252.186.2", port=3306, user="bademsof_mbilal25tr", passwd="k7S30j7r", db="bademsof_appointments")
cur = con.cursor()
cur.execute("INSERT INTO appointments(userno, title, detail, date, time, userid) VALUES '{}', '{}', '{}', '{}', '{}', '{}'".format(self.userno, title, details, date.toPyDate(), time.toPyTime(), self.userID))
cur.close()
con.close()
Kodunu çalıştırdığımda aşağıdaki hatayı alıyorum:
Traceback (most recent call last):
File "E:/Python Projects/AppointmentManager/main.py", line 289, in save_app
cur.execute("INSERT INTO appointments(userno, title, detail, date, time, userid) VALUES '{}', '{}', '{}', '{}', '{}', '{}'".format(self.userno, title, details, date.toPyDate(), time.toPyTime(), self.userID))
File "C:\Python\Python36-32\lib\site-packages\pymysql\cursors.py", line 166, in execute
result = self._query(query)
File "C:\Python\Python36-32\lib\site-packages\pymysql\cursors.py", line 322, in _query
conn.query(q)
File "C:\Python\Python36-32\lib\site-packages\pymysql\connections.py", line 856, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "C:\Python\Python36-32\lib\site-packages\pymysql\connections.py", line 1057, in _read_query_result
result.read()
File "C:\Python\Python36-32\lib\site-packages\pymysql\connections.py", line 1340, in read
first_packet = self.connection._read_packet()
File "C:\Python\Python36-32\lib\site-packages\pymysql\connections.py", line 1014, in _read_packet
packet.check_error()
File "C:\Python\Python36-32\lib\site-packages\pymysql\connections.py", line 393, in check_error
err.raise_mysql_exception(self._data)
File "C:\Python\Python36-32\lib\site-packages\pymysql\err.py", line 107, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''1', 'Bruh', 'Bruh\nBruh', '2017-11-04', '01:00:00', 'BILALS'' at line 1")
MySQL ile çok tecrübeli değilim. Hatam nedir? Teşekkürler…