[GIS] import esri Personal Geodatabase (.mdb) to PostGIS

esri-geodatabasepersonal-geodatabasepostgis

I would like to import an esri Personal Geodatabase (.mdb) to PostGIS.
I have tried to follow the blog post:

How to import esri Personal Geodatabase (.mdb) to PostGIS on Linux

I installed the GDAL tool suite (using gdal-110-1600-x64-core.msi), but whenever I try to run ogr2ogr, I get the following error:

ogr2ogr -f "PostgreSQL" PG:"host=localhost user=penusr dbname=my_pg_db password=my_pg_db_pass port=5432" C:\data\PROVINCES_2013.mdb -a_srs EPSG:26986
ERROR 1: Unable to initialize ODBC connection to DSN for DRIVER=Microsoft Access Driver (*.mdb);DBQ=C:\data\PROVINCES_20
13.mdb,
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
FAILURE:
Unable to open datasource C:\data\PROVINCES_2013.mdb' with the following drivers.
  -> ESRI Shapefile
  -> PostgreSQL
... list of many more.

Does this error typically indicate a problem with connecting to my Postgre DB, or something else? Am I missing some settings? I am fairly sure that the dbname and password are correct.

If I go to the ODBC Data Source Administrator window, I can see that under the Drivers tab PostgreSQL ANSI(x64) and PostgreSQL Unicode(x64) are listed.

Best Answer

Here is how to solve the "data source name not found" issue. ODBC reads the data source name (DSN) from a plain-text file in your home directory called ~/.odbc.ini . Each .mdb file needs a unique DSN written into this file. You may be able to auto-generate it using GUI apps, but the ODBC developer recommends just using your favorite text editor to edit the file.

I have seen and used typically five descriptors for each .mdb:

[nickname_for_odbc_connection]
Description = Whatever description you choose
Driver = {FULLPATH}/libmdbodbc.so
Database = {FULLPATH}/yourfile.mdb
Servername = localhost

Adapt the above five lines to your particular circumstances, and paste them into the ~/.obdc.ini file, and that constitutes a DSN for that file. This seems to solve the "driver not specified" error.

You will need to locate the driver you will use, in order to fill out that {FULLPATH}. Mine was not installed where others show it on their web postings from a few years ago, so the install-pattern of mdbtools may have changed; thus, seek it anew on your own system.