lofith

lofith

Node-Sqlite3-Documentation

API Interface#

https://github.com/TryGhost/node-sqlite3/wiki/API

Note: Even if callback is not used in the code, it will not make the API a synchronous call.

new sqlite3.Database(filename [, mode] [, callback])#

Returns a new Database object and automatically opens the Database object.

  • filename: The valid value is the file name.
  • mode (optional): Optional one or more sqlite3.OPEN_READONLY, sqlite3.OPEN_READWRITE, sqlite3.OPEN_CREATE, sqlite3.OPEN_FULLMUTEX, sqlite3.OPEN_URI, sqlite3.OPEN_SHAREDCACHE, sqlite3.OPEN_PRIVATECACHE. The initial value is OPEN_READWRITE | OPEN_CREATE | OPEN_FULLMUTEX.

  • callback (optional): If this callback (function) is provided, the callback will be called regardless of whether the database is successfully opened or not. Its first argument is an error object (an Error Object), and when the object is null, the database is successfully opened. If the callback is not provided and an error occurs when opening the database, an error event will be called on this database object, and the only parameter of this error event is the error object. If the database is successfully opened, an open event with no parameters will be called regardless of whether a callback is provided or not.

sqlite3.verbose()#

Sets the execution mode to verbose mode to generate long stack traces. There is no way to reset it. For more information, see the debugging wiki page.

Database Database#

close([callback])#

Close the database.

  • callback (optional): If a callback is provided, the function will be called regardless of whether the database is successfully closed or not. Its first argument is an error object (an Error Object), and when the object is null, the database is successfully closed. If the callback is not provided and an error occurs when closing the database, an error event will be called on this database object. If the database is successfully closed, a close event with no parameters will be called.

configure(option, value)#

Sets a configuration option for the database. Valid options are:

  • Tracing & profiling
    • trace: Provides a callback function as the value. Called when executing SQL statements and presents the statement text.
    • profile: Provides a callback function as the value. Called each time an SQL statement is executed.
  • busyTimeout: Provides an integer as the value. Sets busy timeout.

run(sql [, param, ...] [, callback])#

Runs the SQL statement with the specified parameters and calls the callback afterwards. It does not return any results. The function returns a whole database object (Database Object) for use in function chaining when the database object is called.

  • sql: The SQL statement to be executed. If the SQL query is invalid and the callback is not provided, an error event will be called.

Debugging#

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.