jmanna.blogg.se

Node sqlite3
Node sqlite3








node sqlite3

Node sqlite3 install#

Install SQL /* Create the contacts table */ĬREATE TABLE IF NOT EXISTS 'main'.'contacts' ( "contact_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, Application port (this is what eg localhost:1227)Ĭonsole.log("Running application on port: "+port) Var install_sql = fs.readFileSync('./sqlite/sql/install.sql', 'utf-8') Check if a database exists - create if on first runĬonsole.log("Can't find a SQLite database, creating one now.")

node sqlite3

Var sqlite3 = require('sqlite3').verbose() Var db_file = './sqlite/db-rhubarb.sqlite' Var io = require('socket.io').listen(server) Instantiate socket on the http express server Var server = require('http').createServer(app) The code below is only create the first table (and not the others).Įxpress Node JS app calling the SQL on startup // Declare Express

node sqlite3

SQLite though, I don't know as much about (and don't know if I can do what I am trying to do). In Oracle I know I can wrap them all in as follows: BEGIN CREATE TABLE1. I could do them all as separate transactions, but that looks messy and it's much easier to do it all in one call. If it's the first time a user is running the node app (and the SQLite database file does not exist), I want it to run an install SQL script to create all the tables it'll need to work. I'm learning node js at the mo, and using SQLite3 to create a portable project/task/workflow tool (it'll eventually end up on github).










Node sqlite3