Skip to content

Instantly share code, notes, and snippets.

@leandrotoledo
Created June 29, 2012 18:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save leandrotoledo/3019746 to your computer and use it in GitHub Desktop.
Save leandrotoledo/3019746 to your computer and use it in GitHub Desktop.
MDB to PostgreSQL with mdb-tools example
#!/bin/sh
mdb-schema Acadesc.mdb postgres | sed 's/Char/Varchar/g' | sed 's/Postgres_Unknown 0x0c/text/g' | psql -h localhost -U postgres -w -d acadesc > /dev/null 2>&1
tables=$(echo -en $(mdb-schema Acadesc.mdb postgres | grep "CREATE TABLE" | awk '{ print $3 }' | sed -e 's/"//g');)
for i in $tables
do
mdb-export -I postgres Acadesc.mdb $i | psql -h localhost -U postgres -w -d acadesc > /dev/null 2>&1
done
@leandrotoledo
Copy link
Author

!/bin/sh

for TT in $(mdb-tables *.mdb); do
mdb-export -D '%%Y-%%m-%%d %%H:%%M:%%S' *.mdb "$TT" > "${TT}.csv"
done

@zkutch
Copy link

zkutch commented Jul 15, 2017

non comparably faster:

mdb-export -H -Q -q "'" $access_db_file $table | psql -d $postgres_db -c "COPY $table from STDIN with null as ''

text fields with "bad" symbols need additional work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment