Created
July 2, 2014 06:46
-
-
Save hunzai/8484c5bb73ec597185e6 to your computer and use it in GitHub Desktop.
mdb to mysql
This file contains hidden or 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
Excellent - you saved alot of my time. | |
Just one adjustment to the script, you have to add database type with -I option. | |
mdb-export -I 'mysql' -R ';' $mdb $table >> $sql | |
mdb=$1 | |
sql=$2 | |
if [ -z "$2" ]; then | |
echo 'This script convert a MDB file to SQL file. You need to specify the name of both' | |
echo "Usage: $0 <mdb_file> <sql_file>" | |
exit 1 | |
fi | |
if [ -z "$(which mdb-tables)" ]; then | |
echo 'You need mdbtools installed.' | |
echo 'Learn more at http://mdbtools.sourceforge.net/' | |
echo 'If you use Debian/Ubuntu, just execute:' | |
echo ' sudo aptitude install mdbtools' | |
exit 2 | |
fi | |
mdb-schema $mdb > $sql | |
sed -i 's/Long Integer/INT(11)/g; s/Text /VARCHAR/g' $sql | |
for table in $(mdb-tables $mdb); do | |
mdb-export -I 'mysql' -R ';' $mdb $table >> $sql | |
done | |
sed -i '/^-\{2,\}/d; s/DROP TABLE /DROP TABLE IF EXISTS /' $sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment