When I execute sqlite insert query, I get success function callback and result is something link this:
{ "db": {"openargs":{"name":"test","location":"default", "dblocation":"nosync"},"dbname":"test"},
"txlock":"true","readOnly":"false","executes":[]}
Please help with this, it wont happen for other queries like create table...
Which version of the plugin are you using? Which platform is it running on (Android, iOS, Windows) and what version? If on Android, are you using the androidDatabaseImplementation: 2 setting to use the built-in Android SQLite API rather than the bundled version of SQLite?
@sagarhiremath6 it looks like a problem with your code. Please show your INSERT query code to get help thanks!
@brodybits
`db.transaction(function(tx)
{
var insert_sql = "INSERT INTO story( data, status, did, images, userid, imageStatus, videos ) VALUES( ?, ?, ?, ?, ?, ?, ? )";
tx.executeSql( insert_sql, ['fgdfgfd', 'fgfgg', '443', 'nbn', '121', 'nbvnv', 'nvbnv'],
function (resultSet)
{
alert(JSON.stringify(resultSet));
},
function(error)
{
console.log('Insert error: ' + error.message);
}
);
});`
The first parameter for the callback functions is the transaction object tx. The _second_ parameter is the resultSet for the success callback, and the error for the error callback. Your code is dumping the transaction object, not the results of running the query.
@MikeDimmickMnetics : Thanks for noticing. Now I not getting that message
{ "db": {"openargs":{"name":"test","location":"default", "dblocation":"nosync"},"dbname":"test"},
"txlock":"true","readOnly":"false","executes":[]}
But insert is not happening.
@sagarhiremath6 please post a reproduction program.
// In separate function
var db = window.sqlitePlugin.openDatabase({name: 'test', location: 'default'});
// In separate function
db.transaction(
function(tx)
{
var create_story_sql =
'CREATE TABLE IF NOT EXISTS story(id INTEGER PRIMARY KEY AUTOINCREMENT, data TEXT NOT NULL, status TEXT NOT NULL, node INTEGER DEFAULT 0, userid INTEGER NOT NULL, imageStatus TEXT NULL, images TEXT NULL, videos TEXT NULL, created DATETIME DEFAULT CURRENT_TIMESTAMP)';
tx.executeSql( create_story_sql,[], function (tx, results) {
console.log('story table created');
});
},
function(err)
{
console.log('Open database ERROR: ' + JSON.stringify(err));
});
// In separate function
db.transaction(function(tx)
{
var insert_sql = "INSERT INTO story( data, status, images, userid ) VALUES( ?, ?, ?, ?)";
tx.executeSql( insert_sql, ['hfghg', 'ready', 'commaSeparatedImages', 3232],
function (tx, resultSet)
{
alert(JSON.stringify(resultSet));
},
function(error)
{
console.log('Insert error: ' + error.message);
}
);
});
Success callback of Insert query is getting called not error callback.
Success message : { "rows" :{"length" :0}, rowsAffected":1, "insertId":1 }
I am using this sqlite plugin in angurjs+phonegap+bootstrap project. It should work without any issues right? OR Should I use it differently in angularjs. Create database and table are working though.
new transaction is waiting for open operation", source: file:///android_asset/www/plugins/cordova-sqlite-storage/www/SQLitePlugin.js (106)
Seeing above line 3 times in console.
Use of this plugin with Ionic and other forms of Ionic has proven to be very tricky. I already documented some pitfalls that you have to watch for. This may be the same as #593. I leave this to the community for now.
In case of continued problems I suggest you post a complete test project that can demonstrate your issue for community support.
For commercial support you may contact sales@litehelpers.net.
Most helpful comment
The first parameter for the callback functions is the transaction object
tx. The _second_ parameter is theresultSetfor the success callback, and theerrorfor the error callback. Your code is dumping the transaction object, not the results of running the query.