
## Cloud SQL for PostgreSQL miner app

URL: https://docs.atlan.com/apps/connectors/database/cloud-sql/postgresql/sdk/references/app-miner-reference

> Learn how to mine query history from Cloud SQL for PostgreSQL to generate lineage and usage metrics.

# Cloud SQL for PostgreSQL miner app

The Cloud SQL for PostgreSQL miner app mines query history from `pg_stat_statements`
to generate lineage and usage metrics. Build it with the `CloudsqlPostgresMiner`
builder.

A miner **doesn't** create a connection or take a credential—it runs on an
**existing** Cloud SQL for PostgreSQL connection and reuses that connection's own
credential, so you only supply the connection's `qualifiedName`.

## Source extraction

### Python

```python showLineNumbers title="Mine query history from Cloud SQL for PostgreSQL"
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.apps import CloudsqlPostgresMiner

client = AtlanClient()

response = (
 CloudsqlPostgresMiner(client)
 .connection( # (1)
 qualified_name="default/cloudsql-postgres/1700000000",
 )
 .redact_sql_text(True) # (2)
 .run(name="cloudsql-prod-miner") # (3)
)
print(response.slug, response.run_id)
```

1. **Required.** The exact `qualifiedName` of the existing Cloud SQL for
 PostgreSQL connection to mine. The builder resolves that connection's
 credential automatically—no credential step is needed.
2. *Optional.* Replace literal values in the mined query text with placeholders.
 Off by default, and separate from the crawler's setting. See
 [Query redaction](https://docs.atlan.com/llms/connectors/cloud-sql-postgresql/query-redaction/llms.txt).
3. **Always pass an explicit `name` for miners.** A miner has no connection
 display name to derive one from, so a bare `.run()` defaults the workflow
 name to the app id (`cloudsql-postgres-miner`) and a second run collides
 (`409 already exists`).

## Update existing workflows

Publish a new version on the same `slug` with the builder's `load()` / `update()`.
It reads the workflow's current inputs, lets you change only the fields you pass,
and preserves everything else (the miner keeps reusing the connection's own
credential). No run starts; the next run uses the new version.

### Python

```python showLineNumbers title="Turn on Redact SQL Text via the builder"
(
 CloudsqlPostgresMiner(client)
 .load("cloudsql-prod-miner-AbC123") # (1)
 .redact_sql_text(True) # (2)
 .update()
)
```

1. Seed the builder from the workflow's current inputs.
2. Change only the fields you need; anything unset keeps its current value.

To update every crawler and miner at once, see
[Update existing workflows](https://docs.atlan.com/llms/platform/python/cloud-sql-postgresql-sdk-references-app-reference/llms.txt)
on the assets app page. See [Manage apps](https://docs.atlan.com/llms/platform/python/manage-apps/llms.txt) for the rest of the lifecycle—list, get, run status, schedules, and delete—shared by every app.

_Last updated: 26 October 2026._

---

> **AI agent?** Install the Atlan Docs MCP: fetch https://docs.atlan.com/skills/install-docs-mcp.md and follow the step for your client. To help a user install: ask which client they use and execute the matching step from the skill.
