Running queries with node
In the previous chapter, we executed all our queries in a file called .sqlite.db
. We will use this same file to demonstrate how to execute queries and receive their results inside our node process:
/** * Import the SQLite library, and initialize the SQLite db instance * Mention the location of the ".sqlite.db" file that you used in the previous chapter * We want the absolute path of the file, for better clarity, hence, the use of path.resolve * The location inside path.resolve, is the location of the sqlite.db file relative to this one */ const sqlite3 =require('sqlite3') const path =require('path') const db= new sqlite3.Database(path.resolve('./.sqlite.db'))/** * The "serialize" method of the db instance makes sure that all queries directly in its callback are executed sequentially */db.serialize(function() { /** * db.run is used to execute write queries (UPDATE...