Skip to content
  • Auto
  • Light
  • Dark
Get Started

Execute

Execute
client.sqlite.execute(SqliteExecuteParamsbody, RequestOptionsoptions?): columnsarraycolumnTypesarrayrowsarrayrowsAffectednumberlastInsertRowidunionResultSet
post/v1/sqlite/execute

Execute a single SQLite statement and return results

Parameters
bodystatementunionSqliteExecuteParams
Hide ParametersShow Parameters
statementunion
string | argsunionsqlstringParameterizedQuery

Simple SQL statement to run in SQLite

Hide ParametersShow Parameters
string
ParameterizedQuery

A parameterized SQL query. See https://docs.turso.tech/sdk/ts/reference#batch-transactions for reference

Hide ParametersShow Parameters
argsunion
Array<unknown> | Record<string, unknown>

List of arguments to be used in the given statement

Hide ParametersShow Parameters
Array<unknown>
Record<string, unknown>
sqlstring

SQL statement, with ? placeholders for arguments

Returns
columnsarraycolumnTypesarrayrowsarrayrowsAffectednumberlastInsertRowidunionResultSet
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);
200 Example
{
  "columns": [
    "string"
  ],
  "columnTypes": [
    "string"
  ],
  "rows": [
    [
      {}
    ]
  ],
  "rowsAffected": 0,
  "lastInsertRowid": "string"
}