I am trying to add to a table called Users in an Access database I have created. I am using the following code to do it (which has been copied from here):
import pyodbc
def createAccount():
conn = pyodbc.connect(r"Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=myPath\User Database.accdb;")
cursor = conn.cursor()
cursor.execute("""
INSERT INTO Users(Username, Password, Chips)
VALUES("User 5", "Pass 5", 7800)""")
conn.commit()
but I get this error:
pyodbc.Error: ('07002', '[07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters.
Expected 2. (-3010) (SQLExecDirectW)')
I've seen other posts which say to check spelling of all names used and there isn't anything wrong there. So why isn't this code working?
VALUES('User 5', 'Pass 5', 7800)""")