Created
May 27, 2014 16:27
-
-
Save shapr/507bcbf3e8cfdc5d3549 to your computer and use it in GitHub Desktop.
Jython: use Jackcess to csv export all the tables from whatever Jackcess supports, including Access 97, 2000, 2003, 2007, 2010
This file contains 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 characters
# required apt-get install jython libcommons-logging-java libcommons-lang-java | |
import sys | |
sys.path.append('jackcess-2.0.4.jar') # assume the jackcess is in the same directory | |
sys.path.append('/usr/share/java/commons-logging-1.1.3.jar') # in case logging didn't get picked up | |
sys.path.append('/usr/share/java/commons-lang-2.6.jar') # in case lang didn't get picked up | |
from com.healthmarketscience.jackcess import * | |
from com.healthmarketscience.jackcess.util import ExportFilter | |
from com.healthmarketscience.jackcess.util import ExportUtil | |
from com.healthmarketscience.jackcess.util import SimpleExportFilter | |
import java.io | |
from java.io import File | |
dbfilename = sys.argv[1] | |
exportdirname = sys.argv[2] | |
print "input filename is",dbfilename | |
print "tables will be saved into directory",exportdirname | |
dbfile = File(dbfilename) | |
exportdir = File(exportdirname) | |
# make a database object | |
db = DatabaseBuilder.open(dbfile) | |
# make an export filter object | |
export_filter = SimpleExportFilter() | |
# use 'em to throw down all the data! | |
ExportUtil.exportAll(db,exportdir,'csv',True) | |
print "seems to work" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks so much for this! Check out my fork for support for password-protected databases: https://gist.github.com/brandones/58d4b69776fce9dfefffab46783ac203