Skip to content Skip to sidebar Skip to footer

Pulling Ms Access Tables And Putting Them In Data Frames In Python

I have tried many different things to pull the data from Access and put it into a neat data frame. right now my code looks like this. from pandas import DataFrame import numpy as n

Solution 1:

Consider using pandas' direct read_sql method:

import pyodbc
import pandas as pd
...
cnxn = pyodbc.connect('DRIVER={{Microsoft Access Driver (*.mdb, *.accdb)}};DBQ=' + \
                      '{};Uid={};Pwd={};'.format(db_file, user, password)

query = "SELECT * FROM mytable WHERE INST = '796116'"
dataf = pd.read_sql(query, cnxn)
cnxn.close()

Post a Comment for "Pulling Ms Access Tables And Putting Them In Data Frames In Python"