Created
June 29, 2012 18:13
-
-
Save leandrotoledo/3019746 to your computer and use it in GitHub Desktop.
MDB to PostgreSQL with mdb-tools example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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