I have 2 database files in my iOS app:
- An original database (readonly, kept in my app's home directory)
- The user's database (kept in the user's
Documents
folder)
I need to run a SQL query to copy from the original database to the user's, something like:
INSERT INTO UserDatabase.MyTable
SELECT * FROM OriginalDatabase.MyTable;
Is this possible from SQLite running on iOS? The problem is the two databases are in different folder. I would like to avoid doing this work in code (C#) which is the obvious way to do it, just much slower.
My app is written with C#/MonoTouch, but that is probably irrelevant.
Solved with @Peter M's link.
Here is the SQL to do this on iOS:
Note the use of
Main
, this is the database you are connected to withSqliteConnection
, in my case it was located in theDocuments
folder.You can do anything you need against the
OriginalDatabase
, joins, subselects, etc.