Add ~/bin
This commit is contained in:
parent
49133cc8a6
commit
ecd79740fd
199 changed files with 22598 additions and 0 deletions
30
bin/mdb-sqlite.py
Executable file
30
bin/mdb-sqlite.py
Executable file
|
@ -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()
|
Loading…
Add table
Add a link
Reference in a new issue