sqlite
Enable the extension to query the local SQLite database.
Functions
sqlite.sql
sqlite.sql(sql: string): Statement
Execute sql string.
sqlite.exec
sqlite.exec(sql: string): Promise<void>
Execute sql string. Unlike the sqlite.sql
this can execute strings that contain multiple SQL statements. This method performs worse and less safe.
Example
sqlite.open
sqlite.exec(options: OpenOptions): Database
Open existing SQlite database.
Example
Classes
sqlite.Database
An object representing a single SQlite database.
Property | Type | Description |
---|---|---|
execute | (sql: string) => void | Same as the sqlite.exec method |
sql | <T = unknown>(sql: string): Statement<T> | Same as the sqlite.sql method |
close | () => Promise<void> | Close the database connection |
sqlite.Statement
An object representing a single SQL statement.
sqlite.Statement.run
sqlite.Statement.run(…params: unknown[]): Promise<DBRunResult>
Run the sql string and return the changes info it made.
Example
sqlite.Statement.get
sqlite.Statement.get<T = unknown>(…params: unknown[]): Promise<T>
Return the first row retrieved by the query.
Example
sqlite.Statement.all
sqlite.Statement.all<T = unknown>(…params: unknown[]): Promise<T[]>
Return all the match rows.
Example
Types
sqlite.DBRunResult
Result when running the run
statement.
Property | Type | Description |
---|---|---|
changes | number | The total number of rows that were inserted, updated, or deleted by this operation |
lastInsertRowid | number | The rowid of the last row inserted into the database |
sqlite.OpenOptions
Options for the sqlite.open
method;
Property | Type | Description |
---|---|---|
path | string | The SQlite DB file path |