3

I'm new to postgres so this problem is probably a relatively easy one for someone else. However, I have spent many frustrating hours trying to figure out the solution. I have an Access Database of metadata that must be kept updated for sending records to other groups. I also have a database using PostgreSQL and PGAdmin which also has these same metadata tables. Currently these tables in the Postgres database get updated manually by exporting the Access tables as excel files, and then importing them into the SQL tables. It's not the most efficient process and could lead to errors in the SQL database if someone forgets to check before running any queries that they are using the most recent data from Access. So I would like to integrate some of the tables from my Access database with my Postgres database.
Originally I tried just installing drivers to export the Access tables directly to Postgres which worked, but not in the way that I wanted since it just brings in a table which I would still need to manually update. From my understanding, I can create a server connection in postgres to access and that would then bring in updated data using a foreign data wrapper. I tried to use ogr_fdw.

CREATE EXTENSION ogr_fdw;

When I try:

CREATE SERVER metadata FOREIGN DATA WRAPPER ogr_fdw OPTIONS ( datasource 'H:\Databases\20170712.accdb', format 'ODBC' );

I receive: ERROR: unable to connect to data source "H:\Databases\20170712.accdb" SQL state: HV00D

When I try: CREATE SERVER metadata FOREIGN DATA WRAPPER ogr_fdw OPTIONS ( datasource 'H:\Databases\20170712.accdb', format 'ACCDB' );

I receive: ERROR: unable to find format "ADDCB" HINT: See the formats list at http://www.gdal.org/ogr_formats.html.
I also tried MDB and received the same error. However, MDB is the code name given by the website but it says that it needs JDK/JRE to compile and I'm not really sure if that's another type of driver that I would need or what it is.

When I try: CREATE SERVER metadata FOREIGN DATA WRAPPER ogr_fdw OPTIONS ( datasource 'H:\Databases\20170712.mdb', format 'ODBC' );

I receive: ERROR: unable to connect to data source "H:\Databases\20170712.mdb" SQL state: HV00D Hint: Unable to initialize ODBC connection to DSN for DRIVER=Microsoft Access Driver (*.mdb);DBQ=H:\Databases\20170712.mdb, [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

However I thought after looking at the github help page for ogr_fdw didn't need ODBC and special drivers https://github.com/pramsey/pgsql-ogr-fdw/blob/master/FAQ.md.

A lot of this is probably due to my limited knowledge of the terminology when I'm reading through a lot of this stuff. Also my Access database is an .accdb file but since that wasn't working I tried around with mdb and ODBC as the "format" too. If anyone has any suggestions I would greatly appreciate it.
Thanks!

user562
  • 51
  • 1
  • 4

0 Answers0