AnsweredAssumed Answered

Connect to MS Access database with python script

Question asked by Miha_K on May 9, 2018
Latest reply on May 14, 2018 by Miha_K

I am writing a python script. In certain part of the script I would like to create a connection to MS Access database. Based on argument the script would read ID of the municipality and use it for other operations.

 

Below is the part of JS script which connects and reads data from MS Access Database and I would like to use it in python script.

 

appDB = WScript.CreateObject("ADODB.Connection");     
appDB.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Database);//path to database is already defined at the begining of code    
str = "SELECT mun.id, mun.alias FROM mun WHERE (mun.alias)='" + municipality + "';";
appRS = appDB.Execute(str);
midOb = appRS("id").Value;
appRS.close;
appDB.close;


#WScript.Echo(alias);
#WScript.Echo(idMun);
#WScript.Echo(mun_code);

ArcGIS version: 9.1-9.3. I hope you remember old times 

Outcomes