<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Connect to MS Access database with python script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/connect-to-ms-access-database-with-python-script/m-p/449525#M35191</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am writing a python script. In certain part of the script I would like to create a connection to MS Access&amp;nbsp;database. Based on argument the script would read ID of the municipality and use it for other operations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;appDB &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; WScript&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;CreateObject&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"ADODB.Connection"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
appDB&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Open&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; Database&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="comment token"&gt;//path to database is already defined at the begining of code&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;
str &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"SELECT mun.id, mun.alias FROM mun WHERE (mun.alias)='"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; municipality &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"';"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
appRS &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; appDB&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Execute&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;str&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
midOb &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;appRS&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"id"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Value&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
appRS&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;close&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
appDB&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;close&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;


#WScript&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Echo&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;alias&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
#WScript&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Echo&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;idMun&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
#WScript&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Echo&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mun_code&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;ArcGIS version: 9.1-9.3. I hope you remember old times&amp;nbsp;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 20:04:09 GMT</pubDate>
    <dc:creator>MihaKlemencic</dc:creator>
    <dc:date>2021-12-11T20:04:09Z</dc:date>
    <item>
      <title>Connect to MS Access database with python script</title>
      <link>https://community.esri.com/t5/python-questions/connect-to-ms-access-database-with-python-script/m-p/449525#M35191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am writing a python script. In certain part of the script I would like to create a connection to MS Access&amp;nbsp;database. Based on argument the script would read ID of the municipality and use it for other operations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;appDB &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; WScript&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;CreateObject&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"ADODB.Connection"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
appDB&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Open&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; Database&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="comment token"&gt;//path to database is already defined at the begining of code&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;
str &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"SELECT mun.id, mun.alias FROM mun WHERE (mun.alias)='"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; municipality &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"';"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
appRS &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; appDB&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Execute&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;str&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
midOb &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;appRS&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"id"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Value&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
appRS&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;close&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
appDB&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;close&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;


#WScript&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Echo&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;alias&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
#WScript&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Echo&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;idMun&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
#WScript&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Echo&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mun_code&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;ArcGIS version: 9.1-9.3. I hope you remember old times&amp;nbsp;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:04:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/connect-to-ms-access-database-with-python-script/m-p/449525#M35191</guid>
      <dc:creator>MihaKlemencic</dc:creator>
      <dc:date>2021-12-11T20:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to MS Access database with python script</title>
      <link>https://community.esri.com/t5/python-questions/connect-to-ms-access-database-with-python-script/m-p/449526#M35192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another thread was asking a similar question for Pro: &lt;A _jive_internal="true" href="https://community.esri.com/thread/210036-connecting-ms-access-to-arcgis-pro"&gt;Connecting MS Access to ArcGIS Pro&lt;/A&gt;&amp;nbsp;but there was no solution provided.&lt;/P&gt;&lt;P&gt;Perhaps the pyodbc module will provide the connection you require.&amp;nbsp; See:&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/28708772/how-to-connect-ms-access-to-python-using-pyodbc"&gt;How to connect MS Access to Python using pyodbc&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.microsoft.com/en-us/sql/connect/sql-connection-libraries?view=sql-server-2017"&gt;Connection modules for Microsoft SQL databases&lt;/A&gt;&amp;nbsp;and&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.microsoft.com/en-us/sql/connect/python/pyodbc/step-1-configure-development-environment-for-pyodbc-python-development?view=sql-server-2017"&gt;Step 1: Configure development environment for pyodbc Python development&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As an alternative (using Desktop/Catalog not Pro), I have&amp;nbsp;created a new personal geodatabase (which uses the .mdb Access extension).&amp;nbsp;&amp;nbsp; In Access, I can then copy tables from newer .accdb&amp;nbsp;databases into the .mdb&amp;nbsp;version, usually without loss of data.&amp;nbsp; Then the table can be accessed in the personal geodatabase using the usual arcpy tools that are used to process file geodatabases.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is also possible to copy features/tables from a file geodatabase into the personal geodatabase using Catalog.&amp;nbsp; Then using Access, the table can be copied from the .mdb version to the newer .accdb version.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 May 2018 19:05:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/connect-to-ms-access-database-with-python-script/m-p/449526#M35192</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2018-05-10T19:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to MS Access database with python script</title>
      <link>https://community.esri.com/t5/python-questions/connect-to-ms-access-database-with-python-script/m-p/449527#M35193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just use the first pyodbc link &lt;A href="https://community.esri.com/migrated-users/34565"&gt;Randy Burton&lt;/A&gt;‌ provides.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 May 2018 19:33:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/connect-to-ms-access-database-with-python-script/m-p/449527#M35193</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2018-05-10T19:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to MS Access database with python script</title>
      <link>https://community.esri.com/t5/python-questions/connect-to-ms-access-database-with-python-script/m-p/449528#M35194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This video help me the first time I used pyodbc...&amp;nbsp;&lt;A class="link-titled" href="https://www.youtube.com/watch?time_continue=162&amp;amp;v=zw9P2wSnoIo" title="https://www.youtube.com/watch?time_continue=162&amp;amp;v=zw9P2wSnoIo"&gt;Python connection to Access Database using pypyodbc - YouTube&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2018 16:06:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/connect-to-ms-access-database-with-python-script/m-p/449528#M35194</guid>
      <dc:creator>TedKowal</dc:creator>
      <dc:date>2018-05-11T16:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to MS Access database with python script</title>
      <link>https://community.esri.com/t5/python-questions/connect-to-ms-access-database-with-python-script/m-p/449529#M35195</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for answers&amp;nbsp;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;I checked and pyodbc is not installed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternative way is to export MS Access table to .dbf, use&amp;nbsp;arcpy.SearchCursor and get certain row value.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 May 2018 12:00:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/connect-to-ms-access-database-with-python-script/m-p/449529#M35195</guid>
      <dc:creator>MihaKlemencic</dc:creator>
      <dc:date>2018-05-12T12:00:36Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to MS Access database with python script</title>
      <link>https://community.esri.com/t5/python-questions/connect-to-ms-access-database-with-python-script/m-p/449530#M35196</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Installing Python packages is quite easy.&amp;nbsp; Are you not able to install one (locked down machine) or have you just never done it?&amp;nbsp; If the latter, I encourage you to install pyodbc and work with it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you do go with exporting to DBF and using ArcPy cursors, use the &lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/what-is-the-data-access-module-.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/what-is-the-data-access-module-.htm"&gt;What is the data access module?—Help | ArcGIS Desktop&lt;/A&gt; cursors, not the older cursors.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 May 2018 13:34:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/connect-to-ms-access-database-with-python-script/m-p/449530#M35196</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2018-05-12T13:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to MS Access database with python script</title>
      <link>https://community.esri.com/t5/python-questions/connect-to-ms-access-database-with-python-script/m-p/449531#M35197</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's working!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2018 15:37:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/connect-to-ms-access-database-with-python-script/m-p/449531#M35197</guid>
      <dc:creator>MihaKlemencic</dc:creator>
      <dc:date>2018-05-14T15:37:04Z</dc:date>
    </item>
  </channel>
</rss>

