1 min read

The global sql function allows you to query external databases. Supported databases are MySQL and PostgreSQL. The function signature is:

declare const sql: (
  server: string,
  query: string,
  args?: (string | number | boolean)[]
) => Promise<{
  id?: number;
  affectedRows?: number;
  rows: { [k: string]: any }[];

The server is either the name of a suitable secret, or a connection string. Examples of connection strings are:


Query parameters are provided in the query using question marks ("?"). This applies to both MySQL and PostgreSQL. You must provide the respective values in the same order to the args parameter of the sql function.