James Cook
James Cook

Reputation: 344

Inserted records not showing in MS Access DB Table

Having some issues inserting records from pyodbc using sql insert. The code runs and it also looks like MS Access table is generating an ID but the records are not showing in the table.. No Errors in my application , first time using MS Access and pyodbc to insert records. Maybe I need to allow or change setting in Access?

import pyodbc 

conn = pyodbc.connect(r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};UID=admin;UserCommitSync=Yes;Threads=3;SafeTransactions=0;PageTimeout=5;MaxScanRows=8;MaxBufferSize=2048;{FIL=MS Access};DriverId=25;DefaultDir=C:\Users\James\Documents;DBQ=C:\Users\James\Documents\Database1.accdb;')
cursor = conn.cursor()

def add_new_loancar_to_DB(): 
    cursor = conn.cursor()
    cursor.execute( "INSERT INTO Loan_vehicle_data (Loan_make , Loan_model , Loan_rego) values ('test' , 'test' , 'test')")

enter image description here

Upvotes: 0

Views: 134

Answers (1)

user5386938
user5386938

Reputation:

Usually, you'll need to commit your transaction.

conn.commit()

Upvotes: 2

Related Questions