davibe / Phonegap-SQLitePlugin

A phonegap plugin to open and use sqlite databases on iOS.
191 stars 90 forks source link

How to test the plugin if it is working properly #16

Closed ns-1m closed 12 years ago

ns-1m commented 12 years ago

Hi,

I managed to compile this plugin using Phone 1.3.0, however, I don't know how to test if the plugin is working correctly.

Where would we place this script (below) in index.html so it will be executed.

var db; db = new PGSQLitePlugin("test_native.sqlite3"); db.executeSql('DROP TABLE IF EXISTS test_table'); db.executeSql('CREATE TABLE IF NOT EXISTS test_table (id integer primary key, data text, data_num integer)'); db.transaction(function(tx) { return tx.executeSql(["INSERT INTO test_table (data, data_num) VALUES (?,?)", "test", 100], function(res) { console.log("insertId: " + res.insertId + " -- probably 1"); console.log("rowsAffected: " + res.rowsAffected + " -- should be 1"); return db.executeSql("select count(id) as cnt from test_table;", function(res) { console.log("rows.length: " + res.rows.length + " -- should be 1"); return console.log("rows[0].cnt: " + res.rows[0].cnt + " -- should be 1"); }); }, function(e) { return console.log("ERROR: " + e.message); }); });

Any ideas to run this script, so we can see some console logs?

Thanks.

Edit:

I am trying to create something like this.

http://www.digitaldogbyte.com/2011/05/12/using-sqlite-with-phonegap-0-9-5-webos/

But nothing happening in console.log.

It seems my installation is not working.

ns-1m commented 12 years ago

It is working now.

I missed Coffee compiling (make).

[Session started at 2012-03-21 17:19:43 +1100.] 2012-03-21 17:19:47.686 PG13_SQLplugin[14499: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 17:19:50.935 PG13_SQLplugin[14499:207] [INFO] DB opened: test_native.sqlite3 2012-03-21 17:19:54.556 PG13_SQLplugin[14499:207] PluginResult:toJSONString - {"status":1,"message":1,"keepCallback":false} 2012-03-21 17:19:54.583 PG13_SQLplugin[14499:207] PluginResult toSuccessCallbackString: PhoneGap.callbackSuccess('INVALID',{"status":1,"message":1,"keepCallback":false});

This better index.html.

[Session started at 2012-03-21 17:43:46 +1100.] 2012-03-21 17:43:51.502 PG13_SQLplugin[22986: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 17:43:53.812 PG13_SQLplugin[22986:207] PluginResult:toJSONString - {"status":1,"message":1,"keepCallback":false} 2012-03-21 17:43:53.813 PG13_SQLplugin[22986:207] PluginResult toSuccessCallbackString: PhoneGap.callbackSuccess('INVALID',{"status":1,"message":1,"keepCallback":false}); 2012-03-21 17:43:55.475 PG13_SQLplugin[22986:207] [INFO] DB opened: test_native.sqlite3 2012-03-21 17:43:55.501 PG13_SQLplugin[22986:207] [INFO] insertId: 1 -- probably 1 2012-03-21 17:43:55.503 PG13_SQLplugin[22986:207] [INFO] rowsAffected: 1 -- should be 1 2012-03-21 17:43:55.507 PG13_SQLplugin[22986:207] [INFO] rows.length: 1 -- should be 1 2012-03-21 17:43:55.509 PG13_SQLplugin[22986:207] [INFO] rows[0].cnt: 1 -- should be 1