Skip to content

Instantly share code, notes, and snippets.

@togume
Created November 5, 2017 02:56
Show Gist options
  • Save togume/83b4bf40e1528742374bbce338270f34 to your computer and use it in GitHub Desktop.
Save togume/83b4bf40e1528742374bbce338270f34 to your computer and use it in GitHub Desktop.
Shell script to convert Access DB to SQL - Requires mdbtools
#!/bin/bash
TABLES=$(mdb-tables -1 $1)
for t in $TABLES
do
echo "DROP TABLE IF EXISTS $t;"
done
mdb-schema $1 mysql
for t in $TABLES
do
mdb-export -D '%Y-%m-%d %H:%M:%S' -I mysql $1 $t
done
@jerryq27
Copy link

jerryq27 commented Jul 5, 2018

I made some adjustments to this script since I've had issues when I ran it

  • Table names with spaces
  • Values with the ` or ' character
  • Values with back slashes
  • Large Text values from Access being limited to (255) characters

I wanted to submit a pull request, but I can't do that with gists, so I'll link a gist with the changes here instead.

Edit: Fixed broken link.

@dartmann
Copy link

@jerryq27 your gist link is dead

@0x70b1a5
Copy link

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