# Sqlite ## Batch `client.sqlite.batch(SqliteBatchParamsbody, RequestOptionsoptions?): SqliteBatchResponse` **post** `/v1/sqlite/batch` Execute a batch of SQLite statements and return results for all of them ### Parameters - **body:** `SqliteBatchParams` - **statements:** `Array` - `string` - `ParameterizedQuery` A parameterized SQL query. See https://docs.turso.tech/sdk/ts/reference#batch-transactions for reference - **args:** `Array | Record` List of arguments to be used in the given statement - `Array` - `Record` - **sql:** `string` SQL statement, with ? placeholders for arguments - **mode:** `"write" | "read" | "deferred"` - `"write"` - `"read"` - `"deferred"` ### Returns - **SqliteBatchResponse:** `Array` Array of results from the statements executed - **columns:** `Array` Names of columns. Names of columns can be defined using the `AS` keyword in SQL: ```sql SELECT author AS author, COUNT(*) AS count FROM books GROUP BY author ``` - **columnTypes:** `Array` Types of columns. The types are currently shown for types declared in a SQL table. For column types of function calls, for example, an empty string is returned. - **rows:** `Array>` Rows produced by the statement. - **rowsAffected:** `number` Number of rows that were affected by an UPDATE, INSERT or DELETE operation. This value is not specified for other SQL statements. - **lastInsertRowid:** `string | number | null` ROWID of the last inserted row. This value is not specified if the SQL statement was not an INSERT or if the table was not a ROWID table. - `string` - `number` ### Example ```node import ValTown from '@valtown/sdk'; const client = new ValTown({ bearerToken: 'My Bearer Token', }); const resultSets = await client.sqlite.batch({ statements: ['SELECT 1;'], mode: 'read' }); console.log(resultSets); ``` ## Execute `client.sqlite.execute(SqliteExecuteParamsbody, RequestOptionsoptions?): ResultSet` **post** `/v1/sqlite/execute` Execute a single SQLite statement and return results ### Parameters - **body:** `SqliteExecuteParams` - **statement:** `string | ParameterizedQuery` Simple SQL statement to run in SQLite - `string` - `ParameterizedQuery` A parameterized SQL query. See https://docs.turso.tech/sdk/ts/reference#batch-transactions for reference - **args:** `Array | Record` List of arguments to be used in the given statement - `Array` - `Record` - **sql:** `string` SQL statement, with ? placeholders for arguments ### Returns - `ResultSet` ### Example ```node import ValTown from '@valtown/sdk'; const client = new ValTown({ bearerToken: 'My Bearer Token', }); const resultSet = await client.sqlite.execute({ statement: 'SELECT 1;' }); console.log(resultSet.lastInsertRowid); ```