Skip to main content

SQL connectors: PostgreSQL and MySQL

For Studio users with a PostgreSQL or MySQL database and a database user whose grants match what agents may read. The form is the same for both; only Database Type differs.

Before you start: make the database reachable over TLS from your deployment's egress address on the port you will enter (the address is shown as Deployment egress IP on the Snowflake form, or in the Studio installation's network outputs). Studio connects with sslmode=require to PostgreSQL and with TLS by default to MySQL. Agent queries leave the execution environment on TCP 443 only (Execution environments); a database listening on 5432 or 3306 will pass Test Connection but cannot be reached from chat unless it is exposed on 443.

Steps​

  1. Open Data Connectors, click Create Connector, choose SQL Database and fill Connector Name, Description and Connector Guide (write what the database holds; step 5 expands it).
  2. In Connection Configuration ("Where the database lives. Credentials are entered below and stored in AWS Secrets Manager."):
    • Database Type: PostgreSQL or MySQL.
    • Host (placeholder localhost) and Port (placeholder 5432, PostgreSQL's port; type your MySQL port). Neither is marked required, but the test needs both.
    • Database Name: required.
    • Schema (Optional) (placeholder public): for PostgreSQL, Studio's own queries use it as the search path; leave it blank for MySQL.
  3. Enter Username and Password.
  1. Click Test Connection. Studio connects with a 10-second timeout and runs SELECT 1; a tick reads "Connection successful". Nothing is saved.
  2. Click Explore Schema & Enrich Guide. Studio reads tables, columns, relationships and a five-row sample per table and streams a proposed guide. Edit it, then click Accept & Use This Guide (or Discard to keep your text). The result line reads "Schema exploration and guide enrichment completed successfully!".
  1. Click Create Connector (v1). It is enabled when name, description and guide are filled, a database type and database name are set, username and password are entered and, once a test has passed, you have accepted an explored guide.
  2. Open the agent, choose Configure, and add the connector (Agents: configure and activate).

What you should see​

The list shows the connector as SQL "(v1)", Active. The detail page's Configuration shows database type, host, port, database and schema; Credentials shows the username and a masked password with a View toggle.

In chat​

Ask the agent a question about the data. Its code runs in its execution environment and connects with SQLAlchemy and the PostgreSQL or MySQL driver, reading results into a data frame; the guide tells it which tables and columns to use. Credentials are read from the run's environment and are never printed or shown to you.

Notes​

  • Read-only at run time. Queries through the connector accept one statement per request, and only DESC, DESCRIBE, EXPLAIN, SELECT, SHOW and WITH (a WITH may not contain data-modifying or DDL keywords). Anything else is refused: "Statement type 'INSERT' is not allowed. Only read-only statements are permitted: DESC, DESCRIBE, EXPLAIN, SELECT, SHOW, WITH." There is no write mode. When a process must write, have the agent write its proposals as run files and load them with your own process (the loader pattern).
  • Timeouts and caps: 10 seconds to connect (test and exploration); 60 seconds per statement on Studio's own queries (a PostgreSQL statement timeout set server-side; a MySQL read and write timeout); 1,000 rows returned; 5 sample rows per table.
  • Two things connect to the database: Test Connection and exploration from Studio's connector service, and agent queries from the execution environment. Both leave through the deployment's egress address, but the environment's outbound rule allows TCP 443 only, so a test can pass while chat cannot connect.
  • "Connection failed: ...": the driver's error follows the colon; check host, port, firewall, TLS and credentials. "Missing required connection parameters: host, port, or database_name": fill Host and Port.
  • Create Connector (v1) disabled after a passing test: run Explore Schema & Enrich Guide and accept a guide.