Not sure anyone cares, but just in case: the reason I’ve been un-contactable for 6 months (and slow to approve comments) is b/c I’ve been volunteering in Africa at a rural Hospital (see katherineandjohn.org). I helped to get an OpenMRS (openmrs.org) system up and running at the hospital. I think we need more computer science students to do volunteer work overseas and put their skills to good use. Anyway, I’m back in the West and Katherine (my wife) and I are starting to settle in. As soon as I’m programming again (hopefully with an update or two to StarSmasher if time allows) I’ll start blogging again.
It took me awhile to figure this out, and I thought maybe some other people would like to know as well. I found a MySQL export of the King James Version of the Bible that I need for a project I’m working on. It is a huge file and for some reason this was causing sqlite3 some consternation when I attempted the following:
more kjv.sql | sqlite3 kjv.db
For some reason this was giving me errors at lines that when entered by hand weren’t having problems. Since this is, obviously, a huge database I can’t go and fix all these manually. The kjv.sql file was written for MySQL so what I ended up doing was this:
First, I downloaded MAMP (a Mac OS X/Apache/MySQL/PHP one-click installation) because I knew I’d probably want it later and it doesn’t require any type of installation and/or configuration to get MySQL running. I then started the MAMP servers (via MAMP.app). Then I used MAMP’s phpMyAdmin installation to import my kjv.sql file. Then I exported the entire database to a CSV file which was delimited by ‘@’ signs and didn’t put any quotes around the data. The only problem with doing it this way is that carriage returns in the database are treated by sqlite3 as new entries. Fortunately for me this only occurred once. I went into the file with vi, jumped directly to the problem line, got rid of the rogue newlines, and then everything was ready for import.
To import you need to first create your table in your database using sqlite3. After that you run a command similar to:
sqlite3 -separator @ kjv.db “.import kjv_db2-1.csv BibleTable”
If there is an easier way to do this, I’m all ears.