我刚开始使用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()