Connecting to MS Access DB using ODBC package


#1

Hi folks,

I have been using Julia casually for a few months now, I am not a trained programmer in any form.
I am completely stumped on getting the ODBC package working to connect to a single access DB(.accdb) file.

I am trying to replicate something I have working in python where I built the connection strings and then passed them to PyODBC.

I see ODBC.connect() being used from forum posts online, but it doesn’t seem to be a method anymore?

I have read through both versions of the documentation and still cannot get the syntax correct.
What I have so far:

using ODBC

cnxn_str = "Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq="
db = "C:/Path/To/Folder/Scrap.accdb"

#conc. strings
dsin = "$cnxn_str$db"

conn=ODBC.DSN(dsin)

Can I use the ODBC package in this manner or do I need to actually make the file DSN in windows?
What is the correct syntax to connect to a standalone MS access database file?

The access and excel drivers shows up when I run listdsns() so that seems to be working.
I am using Julia 0.5.0 on windows 10, and have the latest version of ODBC.jl installed (0.5.1)

Thank you for your help.


#2

I ended up figuring it out (even though it took a while…).

I uninstalled then re-installed the x64 version of MS access engine Link to MS help site with download

Following that, I can write it as:

cnxn_str=ODBC.DSN("Driver={Microsoft Access Driver (*.mdb, *.accdb)};
 DBQ=C:Path/To/Folder/Scrap.accdb")  #build dsn first

ODBC.query(cnxn_str,"SELECT * FROM Table1") #query to pull table in as dataframe

and now everything seems to be functioning properly.