Are you looking for customized advices? Click here to contact the expert!
by
6,450 23
0
5
451
1
Top 5% !
Popular
Tagged
Specified
OpenSource
Created
Modified Oct 26, 2017

Published on:

Languagejavascript
LanguageNode

sqlite-sync.js

Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/2949367/sqlite-sync-js?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
var sqlite = require('sqlite-sync'); //requiring //Connecting - if the file does not exist it will be created sqlite.connect('test/test.db'); //Creating table - you can run any command sqlite.run("CREATE TABLE COMPANYS(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL);"); //Inserting - this function can be sync to, look the wiki sqlite.insert("COMPANYS",{NAME:"My COMPANY"}, function(inserid){ console.log(inserid); }); //Updating - returns the number of rows modified - can be async too var rows_modified = sqlite.update("COMPANYS",{NAME:"TESTING UPDATE"},{ID:1}); //Create your function function test(a,b){ return a+b; } //Add your function to connection sqlite.create_function(test); // Use your function in the SQL console.log(sqlite.run("SELECT ID, test(NAME, ' Inc') as NAME FROM COMPANYS")); // Closing connection sqlite.close();
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus