Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openDatabase();? How to open an existing database? #13

Closed
ns-1m opened this issue Mar 17, 2012 · 2 comments
Closed

openDatabase();? How to open an existing database? #13

ns-1m opened this issue Mar 17, 2012 · 2 comments

Comments

@ns-1m
Copy link

ns-1m commented Mar 17, 2012

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.

@davibe
Copy link
Owner

davibe commented Mar 18, 2012

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:
#13

@ns-1m
Copy link
Author

ns-1m commented Mar 21, 2012

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

@ns-1m ns-1m closed this as completed Mar 21, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants