exports.allProbes = function() { var rows = db.all("SELECT * FROM probes;"); return rows; };
main: var json_values = allProbes();
Is it possible to do something like that? I mean, without using a callback function: just, read data (sync mode) from the db. and return a json formatted output?
Thanks.
You can synchronize SQLite databases by embedding SymmetricDS in your application. It supports occasionally connected clients, so it will capture changes and sync them when a server comes online. It supports several different database platforms and can be used as a library or as a standalone service.
The sqlite3 module also works with node-webkit if node-webkit contains a supported version of Node. js engine. (See below.) SQLite's SQLCipher extension is also supported.
js and SQLite are separate entities, but both can be used together to create powerful applications. First, we need to link them together by requiring the sqlite3 module. Once we have required this module in our JavaScript, it will give us access to methods to perform various actions with the database.
There are a few npm packages such as better-sqlite3 and sqlite-sync that allow for synchronous SQLite queries. Here's an example:
var sqlite = require("better-sqlite3"); var db = new sqlite("example.db"); var rows = db.prepare("SELECT * FROM probes").all(); console.log(rows);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With