heretolearn
heretolearn

Reputation: 13

Error while importing python o/p to ms access

code I used to establish connection between python code and ms-access

 import pyodbc
    conn = pyodbc.connect(r'Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=D:\LnT_project\Project.accdb;')
    cursor = conn.cursor()
    cursor.execute("Insert into dbtable (File_name, File_size) values(abc, 2)")
    conn.commit()

I am getting this error:

pyodbc.Error: ('07002', '[07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2. (-3010) (SQLExecDirectW)')

Upvotes: 0

Views: 55

Answers (1)

Gustav
Gustav

Reputation: 56026

Try with quotes to mark as a text value:

cursor.execute("Insert into dbtable (File_name, File_size) values('abc', 2)")

Upvotes: 0

Related Questions