Last active
October 28, 2015 04:40
Revisions
-
martjanz revised this gist
Oct 28, 2015 . No changes.There are no files selected for viewing
-
martjanz renamed this gist
Oct 28, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
martjanz created this gist
Sep 26, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ MDB_JET3_CHARSET="cp1252" python mdb2sql.py access.mdb | sqlite3 db.sqlite 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ #!/usr/bin/env python # # AccessDump.py # A simple script to dump the contents of a Microsoft Access Database. # It depends upon the mdbtools suite: # http://sourceforge.net/projects/mdbtools/ import sys, subprocess, os DATABASE = sys.argv[1] # Dump the schema for the DB subprocess.call(["mdb-schema", DATABASE, "mysql"]) # Get the list of table names with "mdb-tables" table_names = subprocess.Popen(["mdb-tables", "-1", DATABASE], stdout=subprocess.PIPE).communicate()[0] tables = table_names.splitlines() print "BEGIN;" # start a transaction, speeds things up when importing sys.stdout.flush() # Dump each table as a CSV file using "mdb-export", # converting " " in table names to "_" for the CSV filenames. for table in tables: if table != '': subprocess.call(["mdb-export", "-I", "mysql", DATABASE, table]) print "COMMIT;" # end the transaction sys.stdout.flush()