Databases

Create and connect to a database

Create a Postgres database and connect with psql over TLS

Create orders and run a query to check the connection.

You need the CLI installed and signed in, psql on your machine, and a selected workspace where you have the admin or editor role. The name orders must be free in that workspace.

Create

This uses the platform's default Postgres version and storage, and the default small size:

nevia pg create orders --wait
nevia pg status orders

The state should be ready, with no pending transition. --wait waits up to 10 minutes. If it times out, creation continues, so track the operation before you go on.

Creation prints the connection and its new password. Save the password if another client needs it. Status and list output omit credentials, but pg connect can read the password back from the machine's configuration.

See nevia pg create for version, size and storage options.

Connect

Print the connection details:

nevia pg connect orders

This prints the host, port, database, user, password and TLS mode. It doesn't open a SQL session. Add --uri to pass the connection to psql:

psql "$(nevia pg connect orders --uri)" -c 'SELECT 1;'

You should see one row containing 1. That confirms the connection works from your machine; ready only says the guest is up.

Keep the URI's sslmode=require or a stricter setting, because routing requires TLS. If the server reports that SSL is unavailable, the deployment needs TLS configured before this connection works.

If pg connect --uri reports no dialable URI, the host or password is unavailable. Run nevia pg status orders. A host reachable only inside the cluster needs deployment networking that allows access from your machine. A sleeping database needs an explicit wake before SQL connections work. Retrieving credentials doesn't wake it.

Reset the password

Reset the password if you lost it, or if pg connect reports it as untracked because someone changed it in SQL:

nevia pg reset-password orders

The command asks for confirmation; --yes approves. The current password stops working, including one set in SQL, and the command prints a new one. A sleeping database keeps its old password until it wakes. The reset applies then, and no password shows until it does. Reset needs a database that is not creating or changing state. In MCP, the reset_database_password tool does the same; see Databases in the Remote MCP server reference.

Use the console's Connect card

In the console, select the same workspace, open Databases, then orders. The Connect card offers three forms:

  • Connection: copy the URI, or the host, port, database, user and password fields separately. The card also shows the required TLS mode.
  • Code: choose psql for a command that uses the URI, or pick an application snippet.
  • Agent: copy a prompt that contains the URI and instructions to verify the connection over TLS.

The URI and the agent prompt include the password.

Next steps

Branch the database to work on a copy, or sleep, wake and delete it. See Database lifecycle states for connection and persistence constraints.

On this page