constructor

bun.SQL.constructor

constructor SQL(
connectionString: string | URL
): SQL;

Creates a new SQL client instance

@param connectionString

Database connection string or URL

const sql = new SQL("postgres://localhost:5432/mydb");
const sql = new SQL(new URL("postgres://localhost:5432/mydb"));
constructor SQL(
connectionString: string | URL,
options: Omit<SQLiteOptions, 'url' | 'filename'> | Omit<PostgresOrMySQLOptions, 'url' | 'filename'>
): SQL;

Creates a new SQL client instance with options

@param connectionString

Database connection string or URL

@param options

Connection and pool options

const sql = new SQL("postgres://localhost:5432/mydb", { idleTimeout: 1000 });
constructor SQL(
options?: Options
): SQL;

Creates a new SQL client instance with options

@param options

Connection and pool options, including the URL or filename

const sql = new SQL({ url: "postgres://localhost:5432/mydb", idleTimeout: 1000 });

Referenced types

class URL

The URL interface represents an object providing static methods used for creating object URLs.

MDN Reference