Skip to content

Examples SQLite Connection

Michael Anderson edited this page Dec 12, 2017 · 1 revision

The SQLite driver connects to a local SQLite file. The SQLite driver supports transactions.

Connection URL

sqlite:///file_path

Usage

const Connection = require('database-js2').Connection;

var connection = new Connection('sqlite:///data.sqlite');

Select Some Data

var Connection = require('database-js2').Connection;

(async () => {
    let connection, statement, rows;
    connection = new Connection('sqlite:///test.sqlite');
    
    try {
        statement = await connection.prepareStatement("SELECT * FROM states WHERE State = ?");
        rows = await statement.query('South Dakota');
        console.log(rows);
    } catch (error) {
        console.log(error);
    } finally {
        await connection.close();
    }
})();