Skip to content

Instantly share code, notes, and snippets.

@ToX82
Created April 3, 2020 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ToX82/051508a7cf15c82b9bcbe02524bd83a0 to your computer and use it in GitHub Desktop.
Save ToX82/051508a7cf15c82b9bcbe02524bd83a0 to your computer and use it in GitHub Desktop.
A quick script that converts a Ms Access database to sql insert files
#!/bin/bash
if [ -z "$1" ]
then
echo "You need to specify the database file. Eg.: ./access_dump.sh my-database.mdb"
echo ""
echo "Please make sure that you have mdbtools installed on your system: 'sudo apt install mdbtools'"
exit 1
fi
DB="$1"
TABLES="$(mdb-tables $DB)"
TABLES=$(echo $TABLES | tr " " "\n")
for TABLE in $TABLES
do
echo "Exporting table: $TABLE"
$(mdb-export -I mysql $DB $TABLE > $TABLE.sql)
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment