Connect with psql and Postgres drivers

Connect psql and standard PostgreSQL drivers to an Antfly Cloud instance over TLS.

Every Antfly Cloud instance speaks the PostgreSQL wire protocol. Connect with psql or the PostgreSQL driver your application already uses, and run SQL against the instance's tables.

Connect#

The username is the instance ID, and the password is a Cloud API key for that instance. Connections use TLS:

PGPASSWORD="$ANTFLY_API_KEY" psql \
  'postgresql://INSTANCE_ID@PGWIRE_HOST:5432/default?sslmode=verify-full'
  • The API key must belong to the instance you connect to.
  • Browser-designated keys can't open PostgreSQL connections. Use a server-side key.
  • Driver connection strings take the same values: instance ID as the user, API key as the password, default as the database, and sslmode=verify-full.

Query#

Write the PostgreSQL dialect you already know: joins, CTEs, window functions, subqueries, INSERT … ON CONFLICT, RETURNING, prepared statements, and cursors.

SELECT c.name, count(*) AS open_tickets
FROM tickets t
JOIN customers c ON c.id = t.customer_id
WHERE t.status = 'open'
GROUP BY c.name
ORDER BY open_tickets DESC
LIMIT 10;

Sessions#

Each client gets a dedicated connection to the instance, so transactions, prepared statements, and cursors work as they do in PostgreSQL. Antfly Cloud checks the key's authority as the session runs: revoking the key or changing its grants disconnects the session. Statements are never retried automatically; if a connection drops during a write, check whether the write applied before retrying it.