5

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.

  • What version of OGR are you running? Issue ogr2ogr --version, at the command line. – klewis Dec 12 '13 at 23:51
  • 1
    It looks like you are having an issue connecting to the MDB file (personal geodatabase), not connecting to the PostGIS database. What do you get if you type ogrinfo C:\data\PROVINCES_2013.mdb ? – RyanDalton Dec 13 '13 at 3:04
  • ogr2ogr --version GDAL 1.10.1, released 2013/08/26 – J21042 Dec 13 '13 at 15:04
  • ogrinfo C:\data\PROVINCES_2013.mdb 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 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 ... – J21042 Dec 13 '13 at 15:05
  • 1
    I downloaded and installed FWTools for windows, and when I ran the same ogr2ogr command in the FWTools shell, it WORKED!! I don't know why it did not work in the GDAL (MSVC 2010 Win64) shell window. Thanks – J21042 Dec 13 '13 at 17:40
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.