Uploading MS Access File to Dash using Upload Component

Hi, I am using the Upload Component from Dash to upload Microsoft Access files but I’m not sure how to acces them afterwards.
I have already seen the example in:
https://dash.plot.ly/dash-core-components/upload
But the pandas.read_sql function is a bit different from the ones used do read an Excel or CSV file.

I’m trying to make an sql query with pandas.read_sql using pyodbc to connect to the ms acees file first. I would normally do something like this:

import pyodbc

path = ‘C:/some/random/path/file.mdb’
odbc_conn_str = ‘DRIVER={Microsoft Access Driver (*.mdb)};DBQ=%s’ % path
conn = pyodbc.connect(odbc_conn_str)

#just an example of a normal query
query = “”“SELECT * FROM [Test]”""
df = pd.read_sql(query, conn)

My question is: Which path should I provide to the conn variable in order to create a succesfull connection with the ms access file that is contained in the contents variable from the Upload Component.

Thank you in advanced, I’ll be waiting for your answer.

Kind Regards,
Catalina

Hi Catalina
I have the same concern, were you able to solve it?

Thank u
María

Hi María,

I wasn’t really able to solve it. However what I did was to supply the user with an input box for the path to the directory of the file and then join the given path with the filename from the upload component.
I hope I could help you.

Best,
Catalina

1 Like

Hi Catalina,
Thank you, I found your information very useful.

Best,
María Fernanda