Skip to content

Connections

Startup SQL

Startup SQL (also called post-connection SQL) runs automatically each time DBCode connects to your database. Use it for the session setup your queries depend on, such as SET statements, search_path, pragmas, temp tables, or attached databases.

  1. Open the connection settings and select Startup SQL
  2. Write the SQL inline, or choose File and pick a .sql file. File paths support variables
  3. Save the connection

Separate multiple statements with semicolons.

DBCode often keeps several connections open to the same database, and reopens them after they sit idle. The script runs on each of those connections, so every query, editor, and notebook sees the same session setup.

Because the script can run many times in one session, keep it quick and safe to repeat. For example, use CREATE TEMP TABLE IF NOT EXISTS rather than CREATE TEMP TABLE.

If a statement fails, DBCode shows the error. A failure while connecting stops the connection so you can fix the script and connect again, and a failure on a later connection is reported by the query that needed it.