Skip to content
  • Auto
  • Light
  • Dark
Get Started
View as Markdown
Copy Markdown

Open in Claude
Open in ChatGPT

Execute

client.sqlite.execute(SqliteExecuteParams { statement } body, RequestOptionsoptions?): ResultSet { columns, columnTypes, rows, 2 more }
post/v1/sqlite/execute

Execute a single SQLite statement and return results

ParametersExpand Collapse
body: SqliteExecuteParams { statement }
statement: string | ParameterizedQuery { args, sql }

Simple SQL statement to run in SQLite

Accepts one of the following:
string
ParameterizedQuery { args, sql }

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

args: Array<unknown> | Record<string, unknown>

List of arguments to be used in the given statement

Accepts one of the following:
Array<unknown>
Record<string, unknown>
sql: string

SQL statement, with ? placeholders for arguments

ReturnsExpand Collapse
ResultSet { columns, columnTypes, rows, 2 more }

Result of executing an SQL statement.

columns: Array<string>

Names of columns.

Names of columns can be defined using the AS keyword in SQL:

SELECT author AS author, COUNT(*) AS count FROM books GROUP BY author
columnTypes: Array<string>

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<Array<unknown>>

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.

Accepts one of the following:
string
number
import ValTown from "npm:@valtown/sdk";

const client = new ValTown({
  bearerToken: 'My Bearer Token',
});

const resultSet = await client.sqlite.execute({ statement: 'SELECT 1;' });

console.log(resultSet.lastInsertRowid);
{
  "columns": [
    "string"
  ],
  "columnTypes": [
    "string"
  ],
  "rows": [
    [
      {}
    ]
  ],
  "rowsAffected": 0,
  "lastInsertRowid": "string"
}
Returns Examples
{
  "columns": [
    "string"
  ],
  "columnTypes": [
    "string"
  ],
  "rows": [
    [
      {}
    ]
  ],
  "rowsAffected": 0,
  "lastInsertRowid": "string"
}