Class Index | File Index

Classes


Class SQLite3

SQLite3 Database handle.

Example:

const SQLite3 = require('sqlite3').SQLite3;
var db = new SQLite3('./my_db.sqlite');
var c = db.cursor('SELECT * FROM table_1 WHERE id IN (?,?)');
c.bind([4,6]);

for (let row in c) {
 print(row.toSource());
}

Defined in: src/plugins/sqlite3/sqlite3.js.
Class Summary
Constructor Attributes Constructor Name and Description
 
SQLite3(dsn)

Opens a handle to the database dsn Will usually be a filename, but could also be ":memory:".

Field Summary
Field Attributes Field Name and Description
<static>  
SQLite3.versionStr

SQLite3 version as human readable string

<static>  
SQLite3.version

SQLite3 version as an integer.

Method Summary
Method Attributes Method Name and Description
 

Close the database handle.

 

Returns the row id of the last inserted column

 
exec(sql, optional_bind_args)

Executes a given SQL statement and optionally, bind parameters can be passed to fill the placeholders in the SQL statement

Note:

If the execution throws an exception and the execution is aborted it will not automatically rollback the applied changes.

 
execMany(sql)

Executes given SQL statement(s).

 

Begin a transaction

 

Commit a transaction

 

Rollback a transaction

 
query(sql, bind_arg)

Get a cursor to execute the given SQL statement.

Class Detail
SQLite3(dsn)

Opens a handle to the database dsn Will usually be a filename, but could also be ":memory:".

Parameters:
dsn

Path to sqlite DB file (or anything else it sqlite3_open supports)

See:
SQLite3.Cursor
Field Detail
<static> {string} SQLite3.versionStr

SQLite3 version as human readable string


<static> {int} SQLite3.version

SQLite3 version as an integer. For example, SQLite v3.6.12 would have a version of 3006012

Method Detail
close()

Close the database handle. Force the database handle to be closed now, instead of when the object gets garbage collected.


lastInsertID()

Returns the row id of the last inserted column

Returns:

the last inserted row id as a number


exec(sql, optional_bind_args)

Executes a given SQL statement and optionally, bind parameters can be passed to fill the placeholders in the SQL statement

Note:

If the execution throws an exception and the execution is aborted it will not automatically rollback the applied changes. If this is wanted the user of this function has to explicitly take care about it by using SQLite3#begin,SQLite3#commit and SQLite3#rollback

Example usage:

 
db.exec('CREATE TABLE foobar (a,b,c)');

db.exec('INSERT INTO foobar VALUES(?,?,?)',[1,2,3]);

db.exec('INSERT INTO foobar VALUES(:first, :second, :third)',
        { first: 4, second: 5, third: 6 });
Parameters:
sql

SQL to execute which might contain placeholders

optional_bind_args

bind parameters passed to SQLite3.Cursor#bind.

Returns:

number of rows affected by the statement


execMany(sql)

Executes given SQL statement(s). Bind parameters can be passed to fill placeholders used in the corresponding SQL statement.

The parameter is expected to be an array of objects with sql and optional bind properties. The bind property should contain a value, an array or an object. The object can be used for named placeholders

Note:

If the execution throws an exception and the execution is aborted it will not automatically rollback the applied changes. If this is wanted the user of this function has to explicitly take care about it by using SQLite3#begin,SQLite3#commit and SQLite3#rollback

Example:

 
db.exec([{ 
       sql: 'CREATE TABLE foobar (a,b,c)'
   }, {
       sql: 'INSERT INTO foobar VALUES(?,?,?)',
       bind: [1,2,3]
   }, {
       sql: 'INSERT INTO foobar VALUES(:first, :second, :third)',
       bind: { first: 4, second: 5, third: 6 }
   }])
Parameters:
sql

SQL statment to execute which can contain placeholders

Returns:

total number of rows affected by the given statements


begin()

Begin a transaction


commit()

Commit a transaction


rollback()

Rollback a transaction


{SQLite3.Cursor} query(sql, bind_arg)

Get a cursor to execute the given SQL statement. Bind parameters can be passed in as parameters the SQL, or by using SQLite3.Cursor#bind.

Parameters:
sql

SQL to prepare.

bind_arg

bind parameters passed to SQLite3.Cursor#bind.

Returns:
{SQLite3.Cursor}

A cursor object


Documentation generated by JsDoc Toolkit 2.1.0 on Wed Nov 18 2009 19:05:15 GMT-0000 (UTC)