At Tarek's suggestion, I wanted to use Core Data rather than sqlite for my project. So I had to convert the data base. I found this tutorial. Using the tutorial as a guide, I used the following python script to convert the one to the other:
import sqlite3; inConn = sqlite3.connect('dictold.sqlite') outConn = sqlite3.connect('dictnew.sqlite') inCursor = inConn.cursor() outCursor = outConn.cursor() maxId = 0 inCursor.execute("select * from lexicon") for row in inCursor: if row[0] > maxId: maxId = row[0] # Create ZLEXICONENTITY entry vals = [] vals.append(row[3]) # Z_PK vals.append(1) # Z_OPT vals.append(2) # Z_ENT vals.append(row[0]) # ZIND vals.append(row[1]) # ZLANG1 vals.append(row[2]) # ZLANG2 outConn.execute("insert into ZLEXICONENTITY values(?, ?, ?, ?, ?, ?)", vals) outConn.execute("update Z_PRIMARYKEY set Z_MAX=?", [maxId]) outConn.commit()
It worked!
I thought I would post this here as maybe others have this need.
To execute this script:
1. Make backups of your old database, as well as the app..
2. Create your CoreData Model.
3. Run your app without a db. xCode will give an error, but it will make an empty database that you can use for core data.
4. Save that empty database and use a copy for the next steps.
5. Go to terminal.app
6. "python db.py" (or whatever you named your script).
7. review the new database however you want (it took me a few attempts to get the columns and rows correct).
8. Add the new db into your app.
Hope this helps
David