strix-cz / sqlite3-transactions Goto Github PK
View Code? Open in Web Editor NEWAdds transactions support to node-sqlite3.
Adds transactions support to node-sqlite3.
hello
i started to use sqlite3-transactions
but when i try to use it i got that error
(node:6747) DeprecationWarning: sys is deprecated. Use util instead.
my nodejs version 6.1.0
also i tested it in V6.0.0 and i got the same error
regards
Hi there, I'd like to use transactions with sqlite3, but it seems like this library has not received a lot of love recently. Does node-sqlite3 now support transactions? I don't see that in their docs.
There is a bug, when I execute some queries after commit (inside callback). I keep getting:
node_modules\sqlite3-transactions\sqlite3-transactions.js:135
object[method].apply(object, args);
Here is test code:
var TransactionTest = function () {
var testBeginId = 0;
var transaction = function (err, transaction) {
for (var i = 0; i < 30; i++) {
transaction.run("INSERT INTO _test (Var1, Var2) VALUES (?,?)", i, i + 5);
}
transaction.commit(function (err) {
if (err) {
console.log(err);
db.exec("DELETE FROM _test WHERE Id = ?", 1);
return;
}
db.exec("UPDATE _test SET Var2 = ? WHERE Id = ?", 'update', testBeginId);
});
};
db.run("INSERT INTO _test (Var1, Var2) VALUES ('TestBegin', datetime())", function (err) {
if (err) {
console.log(err);
return;
}
testBeginId = this.lastID;
db.beginTransaction(transaction);
});
};
TransactionTest();
Hi
I was testing your node module, the test i made was to put intencionally a error in one query in a list of queries to generate a rollback, but every error dead the app, i tried to capture error putting the commit funcion in a try catch, but the app died with any error in a query by error native.
`transaction i'm use
db.beginTransaction(function(err, transaction){
try {
for (var key in listQueries) {
transaction.run(listQueries[key]);
}
transaction.commit(function (err) {
callback(err);
});
}
catch(err){
logger.write(err, logger.level.ERROR);
callback(err);
}
});`
Line 250 in sqlite3-transactions.js
Changing 'er' to 'err' fixes the issue.
We are looking at using sqlite3-transactions in the azure-mobile-apps product. I notice you have fixed the warning about the sys
module being deprecated, but this has not hit npm.
Any chance you could publish an update? Your module will likely get significant usage and testing if we proceed.
var sqlite3 = require('sqlite3').verbose();
var TransactionDatabase = require("sqlite3-transactions").TransactionDatabase;
var db = new TransactionDatabase( new sqlite3.Database(":memory:") );
db.run( ....
db is undefined...
However, if no TransactionDatabase is used, the above run statement would work...
I did place the run statement in a call back for the sqlite3 new database call and that seems to work..
Running this on a nwjs-compiled sqlite3 in nwjs
db.run ("CREATE TABLE `test` (`index` INTEGER) PRIMARY KEY(`INTEGER`);");
db.beginTransaction(function(err, transaction) {
transaction.run("INSERT ..."); //left this in by accident and even this did not trigger a rollback
for (var i = 0; i < 3; i++) {
transaction.run("INSERT INTO `test` VALUES (1);");
}
transaction.commit(function(err) {
if (err) return console.log("Sad panda :-( commit() failed.", err);
console.log("Happy panda :-) commit() was successful.");
});
});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.