我在这段代码中遇到语法错误,该软件说pyodbc错误42000然而我无法看到错误

时间:2018-06-11 10:42:06

标签: python sql

我的代码中出现错误,我无法识别问题

current_path=os.path.dirname(__file__)
find_database=os.path.join(current_path, "RDdatabase.accdb")
connection=pyodbc.connect('Driver={Microsoft Access Driver (*.mdb, 
*.accdb)}; dbq=%s;' %find_database)
cursor=connection.cursor()

AMorPM = str(self.ui.timedropdown.currentText())
editedTime = str((self.ui.timelineedit.text())+" "+AMorPM)

cursor.execute("insert into 
Appointments(customername,time,service) 
values(?,?,?)",self.ui.customernamelineed 
it.text(),editedTime,
self.ui.servicelineedit.text())

connection.commit()
connection.close()
self.clearedboxes()#function to clear boxes
QtGui.QMessageBox.about (self, 'Added to database', 'The record has been 
added to the database.')

错误在插入语句中,任何帮助都将不胜感激

Traceback (most recent call last):
  File "addappointment.py", line 35, in addappointment
    cursor.execute("insert into Appointments(customername,time,service)values(?,?,?)"
 ,self.ui.customernamelineedit.text(),editedTime,
  self.ui.servicelineedit.text())#inserts the values into a table
pyodbc.ProgrammingError: ('42000', '[42000] 
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. 
(-3502) (SQLExecDirectW)')

0 个答案:

没有答案