Batch SQL queries
https://{your-workspace-slug}.{region}.xata.sh/db/db_branch_name/sql/batchThis endpoint performs the SQL query across the entire database branch. Set your SQL query in the parameter query.
Expected parameters
| Name | Description | In | Required | Schema |
|---|---|---|---|---|
db_branch_name | The DBBranchName matches the pattern | path | ✅ | string |
Batch SQL Queries
POSThttps://{your-workspace-slug}.{region}.xata.sh/db/db_branch_name/sql/batchRun multiple SQL queries across the database branch.
Request Body Type Definition
type SqlBatchQuery = {
/**
* The SQL statements.
*/
statements: PreparedStatement[];
consistency?: SQLConsistency;
responseType?: SQLResponseType;
};
type PreparedStatement = {
/**
* The SQL statement.
*
* @minLength 1
*/
statement: string;
/**
* The query parameter list.
*/
params?: any[] | null;
};
/**
* @default strong
*/
type SQLConsistency = "strong" | "eventual";
/**
* @default json
*/
type SQLResponseType = "json" | "array";Responses
type SqlBatchQuery = {
results: SQLResponse[];
};
type SQLResponse = SQLResponseJSON | SQLResponseArray;
type SQLResponseJSON = SQLResponseBase & {
records: SQLRecord[];
};
type SQLResponseArray = SQLResponseBase & {
rows: any[][];
};
type SQLResponseBase = {
/**
* Name of the column and its PostgreSQL type
*/
columns: {
name: string;
type: string;
}[];
/**
* Number of selected columns
*/
total: number;
warning?: string;
};
/**
* Xata Table SQL Record
*/
type SQLRecord = {
[key: string]: any;
};type SqlBatchQuery = {
id?: string;
message: string;
};{
"message": "invalid API key"
}type SqlBatchQuery = {
id?: string;
message: string;
};type SqlBatchQuery = {
id?: string;
message: string;
};type SqlBatchQuery = void;type SqlBatchQuery = void;