Monday, June 2, 2014

Importing data from one sqlite database to another



After some problems with Jano, a core data application for IOS, I had to take the data from an older database and put it in a new file. For this I started the Terminal application and typed sqlite, then hit Enter.

The first thing to do was to attach the 2 databases using the following command:

attach database "/Users/puiu/Documents/Jano.sqlite" as 'jano';
attach database "/Users/puiu/Documents/JanoNew.sqlite" as 'janonew';

Inserting the data was quite easy, using a simple SQL statement:

insert into janonew.zcounters(z_ent, z_opt, zisspecial, zordinal,zparent,zhiragana,zkanji,zromaji) 
select z_ent, z_opt, zisspecial, zordinal,zparent,zhiragana,zkanji,zromaji from jano.zcounters;

No comments:

Post a Comment