无法使用pyodbc

时间:2019-11-22 02:12:57

标签: python pyodbc

我刚开始使用python将条目插入SQL数据库。我能够从数据库中读取值,但是插入会给我一个错误:

"('42000', "[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Incorrect syntax near the keyword 'User'."

这是我的代码:

userName = getpass.getuser()      
queryNewUnit = "INSERT INTO AllUnits (Unit, User, Time) VALUES (?, ?, ?)"

curForAdd.execute(queryNewUnit, (userEntry, userName, datetime.now()))
conForAdd.commit()

0 个答案:

没有答案