JSPM

siennasql

1.0.1
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 4
    • Score
      100M100P100Q24003F
    • License MIT

    A clone of sqlite-sync with foreign keys enforced.

    Package Exports

    • siennasql
    • siennasql/sqlite-sync.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (siennasql) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    siennasql.js

    Node module to sqlite sync and async

    This is an almost clone of the sqlite-sync package, except it has foreign keys enforced.

    node.js package for database connection with SQLite , and execute SQL commands synchronously or asynchronously.

    Install

    npm install siennasql

    Usage

    var sqlite = require('siennasql'); //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);",function(res){
        if(res.error)
            throw res.error;
        console.log(res);
    });
    
    //Inserting - this function can be sync to, look the wiki
    sqlite.insert("COMPANYS",{NAME:"My COMPANY"}, function(res){
        if(res.error)
            throw res.error;
        console.log(res);
    });
    
    //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();