Connecting to Microsoft Access Database using Python

Source Code ->


import pypyodbc

# Create connection - make sure you change the file paths accordingly 
con = pypyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};UID=admin;UserCommitSync=Yes;Threads=3;SafeTransactions=0;PageTimeout=5;MaxScanRows=8;MaxBufferSize=2048;FIL={MS Access};DriverId=25;DefaultDir=C:/Users/Rob/Documents/py_sql_tutorial;DBQ=C:/Users/Rob/Documents/py_sql_tutorial/Database1.mdb;')

cursor = con.cursor()

cursor.execute("SELECT customer_table.password FROM customer_table")

for row in cursor.fetchall():
    print(row)

con.close()