nomoslogos
asked on
Can't write to MSAccess database with pyodbc
I am using the Python code below to write to an MSAccess DB through ODBC. I don't get any errors, I know the database is being accessed because it creates a key, but the database isn't close (until I close the Python session) because the key doesn't go away. But no data is getting written to the database.
Can anyone see what I am not?
btw, Customer_ID is an integer.
import pyodbc
cnxn = pyodbc.connect("DSN=proddb ")
cnxn.execute("INSERT INTO tblParts (Part_Number, Part_Description, Customer_ID, Part_Type) VALUES ('856854-001', 'BASEFRAME', 421, 'NA')")
cnxn.close
Can anyone see what I am not?
btw, Customer_ID is an integer.
import pyodbc
cnxn = pyodbc.connect("DSN=proddb
cnxn.execute("INSERT INTO tblParts (Part_Number, Part_Description, Customer_ID, Part_Type) VALUES ('856854-001', 'BASEFRAME', 421, 'NA')")
cnxn.close
ASKER
Also, no error messages are generated...
>>>
>>>
>>>
>>>
Where you have this:
cnxn.close
you need this:
cnxn.close()
Without the (), the function doesn't get called.
cnxn.close
you need this:
cnxn.close()
Without the (), the function doesn't get called.
ASKER
Thanks RichieHindle, it does open & close the database now, but still no data is getting written. Maybe it has to be opened in a specific mode?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks again, RichieHindle! That was it!
ASKER