Docs

API: methods

Full method reference for CapacitorSqlite. See Concepts for the SqliteResult contract that every method shares, and Types for the option/result interfaces linked below.

Plugin metadata

getPluginPlatform()

getPluginPlatform(): Promise<SqliteResult<{ platform: SqlitePlatform }>>

Returns the platform identifier of the implementation answering calls ('ios' | 'android' | 'web' | 'electron').

isAvailable()

isAvailable(): Promise<SqliteResult<{ available: boolean }>>

Returns true if SQLite is available on the current platform. Call this before assuming persistent-storage support; ':memory:' databases work even when it reports false.

Database lifecycle

open(options)

open(options: OpenOptions): Promise<SqliteResult>

Opens (or creates) a database. If migrations are supplied, pending migrations are applied before the Promise resolves. Returns MIGRATION_FAILED if a migration entry is malformed, versions are duplicated, or a migration statement fails. See Migrations.

close(options)

close(options: { database: string }): Promise<SqliteResult>

Closes the database connection. Automatically rolls back any open manual transaction first.

isOpen(options)

isOpen(options: { database: string }): Promise<SqliteResult<{ open: boolean }>>

getVersion(options)

getVersion(options: { database: string }): Promise<SqliteResult<{ version: string }>>

Returns the SQLite engine version string for the opened connection.

getSchemaVersion(options)

getSchemaVersion(options: { database: string }): Promise<SqliteResult<{ version: number }>>

Returns the current PRAGMA user_version for the opened database.

vacuum(options)

vacuum(options: { database: string }): Promise<SqliteResult>

Runs SQLite VACUUM for the opened database.

SQL operations

execute(options)

execute(options: ExecuteOptions): Promise<SqliteResult<{ changes: number }>>

Executes one or more SQL statements sequentially. Use for DDL or bulk DML without parameters. statements must be a non-empty array; each element must be exactly one SQL statement — a semicolon-separated string of statements fails on every platform. Runs in a single transaction by default; pass transaction: false to keep prior successful statements if a later one fails, or when calling this inside an active beginTransaction() (nested transactions return TRANSACTION_FAILED). See Usage.

run(options)

run(options: RunOptions): Promise<SqliteResult<{ changes: number; lastInsertId: number }>>

Executes a single parameterized statement. lastInsertId is 0 for non-insert statements, for INSERT/REPLACE with an ON CONFLICT clause, and whenever SQLite's connection-level rowid counter is otherwise unchanged. Use query() with RETURNING when the exact affected row's id is required. See Usage.

runBatch(options)

runBatch(options: RunBatchOptions): Promise<SqliteResult<{ changes: number; lastInsertId: number }>>

Executes multiple parameterized statements in a single native call — for mixed-SQL bulk writes. lastInsertId on the result is always 0. See Bulk writes.

runMany(options)

runMany(options: RunManyOptions): Promise<SqliteResult<RunManyResult>>

Executes one parameterized statement for many value sets in a single call. Unlike runBatch(), the SQL text is transported and classified only once. lastInsertId on the aggregate result is always 0; set returnResults: true to get per-execution changes/lastInsertId. See Bulk writes.

query<T>(options)

query<T = Record<string, unknown>>(options: QueryOptions): Promise<SqliteResult<{ rows: T[] }>>

Executes a result-producing statement and returns rows as plain objects. Supported forms: SELECT, PRAGMA, EXPLAIN, and INSERT/UPDATE/DELETE/REPLACE ... RETURNING. DML without RETURNING returns INVALID_PARAMS — use run() instead. See Usage.

Transactions

beginTransaction(options)

beginTransaction(options: { database: string }): Promise<SqliteResult>

Starts a manual transaction. Returns TRANSACTION_FAILED if one is already active on that connection.

commitTransaction(options)

commitTransaction(options: { database: string }): Promise<SqliteResult>

rollbackTransaction(options)

rollbackTransaction(options: { database: string }): Promise<SqliteResult>

See Transactions for the full lifecycle pattern and nesting rules.

Next

Types for every option/result interface referenced above, or Error codes for what SqliteError.code can be and why.

Last updated on July 17, 2026