Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a few DB's which I can access through pgAdmin 3, I have a piece of software that can only analyze .mdb files. does anyone know how to convert/export a postgres db to a mdb? preferably through pgAdmin 3?


share|improve this question
up vote 2 down vote accepted

You should be able to use MS Access files using ODBC (if you have a windows box available). With that you can write a small script to dump the database from one format to the other, e.g. with python using obdc, pyodbc or mxODBC packages.

a simple example can be (running on windows, not really tested, you will need to download the psycopg2 package, probably):

import odbc, psycopg2

odbc_conn = odbc.odbc("DSN=MY_ACCESS_DATABASE")
pg_conn = psycopg2.connect("host=server_name dbname=my_db user=godot password=???")

pg_curs = pg_conn.cursor()
odbc_curs = odbc_conn.cursor()

pg_curs.execute('select * from my_table')
for row in pg_curs.fetchall():
    # The format depends on your table, of course
    # With more work you can make it more generic, generating the 
    # format string from the type of the columns
    odbc_curs.execute('insert into my_table values (%s,%d,%d)' % row)
share|improve this answer
could you point me to any tutorials on how to do this? – Aly Mar 9 '10 at 14:50
Accessing databases in python is fairly easy, since there is a standard interface (DBI). I editing the answer for more info. – Dan Andreatta Mar 11 '10 at 9:45

.MDB is MS Access, right? I doubt pgAdmin 3 being able to do that. If Access can handle SQL then you can probably dump the Postgres databases to plain text SQL and load it into Access (with small changes, I'm guessing). If not, then you probably have to write a small program that reads from Postgres and writes to Access/MDB. Maybe there exists one already. Most converters I found using Google go in the other direction.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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