title: Linking Access tables into a PostgreSQL Database using a foreign data wrapper
body: <p>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.<br>
  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.</p>
  
  <pre><code>CREATE EXTENSION ogr_fdw;
  </code></pre>
  
  <p>When I try:</p>
  
  <p><code>CREATE SERVER metadata
        FOREIGN DATA WRAPPER ogr_fdw
        OPTIONS (
        datasource 'H:\Databases\20170712.accdb',
        format 'ODBC' );</code></p>
  
  <p>I receive: ERROR: unable to connect to data source "H:\Databases\20170712.accdb"
  SQL state: HV00D</p>
  
  <p>When I try:
  <code>CREATE SERVER metadata
        FOREIGN DATA WRAPPER ogr_fdw
        OPTIONS (
        datasource 'H:\Databases\20170712.accdb',
        format 'ACCDB' );</code></p>
  
  <p>I receive: ERROR:  unable to find format "ADDCB"
  HINT:  See the formats list at <a href="http://www.gdal.org/ogr_formats.html" rel="nofollow noreferrer">http://www.gdal.org/ogr_formats.html</a>.<br>
  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.  </p>
  
  <p>When I try:
  <code>CREATE SERVER metadata
        FOREIGN DATA WRAPPER ogr_fdw
        OPTIONS (
        datasource 'H:\Databases\20170712.mdb',
        format 'ODBC' );</code></p>
  
  <p>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</p>
  
  <p>However I thought after looking at the github help page for ogr_fdw didn't need ODBC and special drivers <a href="https://github.com/pramsey/pgsql-ogr-fdw/blob/master/FAQ.md" rel="nofollow noreferrer">https://github.com/pramsey/pgsql-ogr-fdw/blob/master/FAQ.md</a>.</p>
  
  <p>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.<br>
  Thanks!</p>