Skip to content

Instantly share code, notes, and snippets.

@kazlauskis
Created September 8, 2016 13:26
Show Gist options
  • Save kazlauskis/1d0bdb9efb3b1bb1e76d48aa368f3a64 to your computer and use it in GitHub Desktop.
Save kazlauskis/1d0bdb9efb3b1bb1e76d48aa368f3a64 to your computer and use it in GitHub Desktop.
Transforms MS Access MDB file to sqlite database using mdbtools
#!/bin/bash
# Inspired by
# https://www.codeenigma.com/community/blog/using-mdbtools-nix-convert-microsoft-access-mysql
# USAGE
# Rename your MDB file to migration-export.mdb
# run ./mdb2sqlite.sh migration-export.mdb
# wait and wait a bit longer...
mdb-schema migration-export.mdb sqlite > schema.sql
mkdir sqlite
mkdir sql
for i in $( mdb-tables migration-export.mdb ); do echo $i ; mdb-export -D "%Y-%m-%d %H:%M:%S" -H -I sqlite migration-export.mdb $i > sql/$i.sql; done
mv schema.sql sqlite
mv sql sqlite
cd sqlite
cat schema.sql | sqlite3 db.sqlite3
for f in sql/* ; do echo $f && cat $f | sqlite3 db.sqlite3; done
@swiftgeek
Copy link

swiftgeek commented Jun 19, 2025

Today, on my system, it needs extra --quote=\' passed to mdb-export in order to make it work due to sqlite changes, that make it not accept double quotes anymore

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