External Exam Download Resources Web Applications Games Recycle Bin

Access


download Microsoft ODBC Driver 13 for SQL Server, 64 bit:

install ODBC Driver:

Open cmd.exe as administrator, type pip install pyodbc:

put access database somewhere easy to find:

change location string in python code to point to your database:

import pyodbc
driver = "Driver={Microsoft Access Driver (*.mdb, *.accdb)};"
location = "DBQ=C:\\access\\shop.accdb"
connection = pyodbc.connect(driver + location)
cursor = connection.cursor() #for traversal of records
resultSet = cursor.execute("SELECT * FROM customers")
for row in resultSet:
    print(row.firstName)
cursor.close()
connection.close()

run in IDLE or favourite IDE: