Closed ns-1m closed 12 years ago
The string you pass to the PGSQLitePlugin constructor is a the db filename. This filename is joined with the appData directory to create a full db path.
Then sqlite3_open gets called with the full db path. This function automatically creates a new db if the file does not exsists otherwise it opens the existing one.
see https://github.com/davibe/Phonegap-SQLitePlugin/blob/master/Plugins/PGSQLitePlugin.m#L42
Davide Bertola
On Mar 18, 2012, at 12:36 AM, Noli Sicad wrote:
In WebSQL / indexDB:
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
http://www.tutorialspoint.com/html5/html5_web_sql.htm
############
Now, how to we open a database (i.e. openDatabase) with the existing sqlite database (e.g. myLocation.sqlite3)
var db = openDatabase ( )
#############
In the example Readme.
var db; db = new PGSQLitePlugin("test_native.sqlite3");
Is the "test_native.sqlite3" would be created in the above snippet (i.e new) or can be existing database?
How can we open an existing Sqlite3 database (e.g. myOldLocation..sqlite3)?
Reply to this email directly or view it on GitHub: https://github.com/davibe/Phonegap-SQLitePlugin/issues/13
Yes, it opens existing database.
[Session started at 2012-03-21 22:10:46 +1100.] 2012-03-21 22:11:02.715 PG13_SQLplugin[18739:207] Device initialization: DeviceInfo = {"name":"iPad Simulator","uuid":"00000000-0000-1000-8000-000000000000","platform":"iPad Simulator","gap":"1.3.0","version":"4.3","connection":{"type":"wifi"}}; 2012-03-21 22:11:04.832 PG13_SQLplugin[18739:207] PluginResult:toJSONString - {"status":1,"message":1,"keepCallback":false} 2012-03-21 22:11:04.834 PG13_SQLplugin[18739:207] PluginResult toSuccessCallbackString: PhoneGap.callbackSuccess('INVALID',{"status":1,"message":1,"keepCallback":false}); 2012-03-21 22:11:06.491 PG13_SQLplugin[18739:207] [INFO] DB opened: AusPostCode.sqlite3 2012-03-21 22:11:06.510 PG13_SQLplugin[18739:207] [INFO] insertId: 1 -- probably 1 2012-03-21 22:11:06.513 PG13_SQLplugin[18739:207] [INFO] rowsAffected: 1 -- should be 1 2012-03-21 22:11:06.517 PG13_SQLplugin[18739:207] [INFO] rows.length: 1 -- should be 1 2012-03-21 22:11:06.518 PG13_SQLplugin[18739:207] [INFO] rows[0].cnt: 1 -- should be 1 2012-03-21 22:11:08.446 PG13_SQLplugin[18739:207] [INFO] insertId: undefined -- probably 1 2012-03-21 22:11:08.448 PG13_SQLplugin[18739:207] [INFO] rowsAffected: 1 -- should be 1 2012-03-21 22:11:08.452 PG13_SQLplugin[18739:207] [INFO] rows.length: 1 -- should be 1 2012-03-21 22:11:08.453 PG13_SQLplugin[18739:207] [INFO] rows[0].cnt: 1 -- should be 1
In WebSQL / indexDB:
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
http://www.tutorialspoint.com/html5/html5_web_sql.htm
Now, how to we open a database (i.e. openDatabase) with the existing sqlite database (e.g. myLocation.sqlite3)
var db = openDatabase ( )
In the example Readme.
var db; db = new PGSQLitePlugin("test_native.sqlite3");
Is the "test_native.sqlite3" would be created in the above snippet (i.e new) or can be existing database?
db.executeSql('DROP TABLE IF EXISTS test_table');
It seems also extisting (noticing the above line).
Anyway, I just like to make it sure, how to open existing databases.