> ## Documentation Index
> Fetch the complete documentation index at: https://deepline.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Query a database | Human guide

> Ask your agent to inspect and query the right customer data.

```deepline-prompt theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
/deepline-gtm Answer [question] from [database] with a bounded read-only query. Explain the population and what each row represents.
```

The agent inspects schema and access in the intended customer database, then answers your business question with a bounded read-only query. It reports the population, columns, filters, and what each row represents.

Name the database and question, and state whether the work is read-only. Deepline-managed views and your own tables have different write rules. A connected external Postgres database is a separate destination.

> [!TIP]
>
> An empty successful query differs from a permission failure. Check truncation and missing access before interpreting the answer, and approve writes to your own permitted objects separately.

## Query an external Postgres database

> [accordion] Use your own connected Postgres database
>
> Ask for the same bounded read from your connected external database, naming
> the intended provider and database. An owner or admin first saves the
> [Postgres credentials](https://deepline.com/docs/features/bring-your-own-keys.md#external-postgres) in
> Integrations; use the Supabase Session Pooler procedure when applicable.
>
> The agent inspects tables and declared relationships before joining data.
> `postgres_run_query` uses that saved connection, not Deepline's Database API.
> The external database role determines write permissions: use a read-only role
> to prohibit writes. Mutations and schema changes have no extra write toggle.
> Keep credentials out of the prompt, bound the query, and inspect result limits.

## Related guides

* [Database reference](https://deepline.com/docs/features/postgresql-database.md)
* [Database](https://deepline.com/docs/data-lifecycle.md)
* [Runtime API Reference](https://deepline.com/docs/sdk-v2/api-reference.md)

[Review and operate a workflow](https://deepline.com/docs/human/templates.md#review-and-operate-a-workflow) covers authorization, pilots, and recovery.

[Agent guide: CLI and SDK instructions →](https://deepline.com/docs/database-access.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.