Skip to main content
Plenty of the data worth reconciling never becomes a file. It sits in a database, and getting it into Darpan has meant someone exporting a CSV on a schedule and hoping the export and the reconciliation stay in step. A database source removes that step: Darpan connects, runs a query you wrote, and feeds the rows into the same reconciliation pipeline that files and APIs use. A database source is two pieces. A connection says where the database is and how to authenticate. A query says which records to compare. One connection can carry many queries.
The app has no screens for database sources in this release. A database source is set up through the facade.DatabaseFacadeServices.* JSON-RPC methods, or by an operator on your behalf. Once saved, it is used by a run or automation like any other source.

Before you start

Confirm:
  • You are a Tenant user, Company editor or Tenant admin in the tenant, and the correct tenant is active.
  • The database is MySQL, PostgreSQL, or IBM Db2. Darpan rejects any other dialect.
  • The database is reachable from the Darpan deployment, and you have a username and password for it.
  • You have a read-only account. Darpan only ever issues SELECT, but a read-only credential means a mistake in a query cannot become a mistake in your database.
  • You know whether the server offers TLS, and, if its certificate is signed by a private certificate authority, you have that authority’s certificate in PEM form.

Create the connection

Save the connection with facade.DatabaseFacadeServices.save#DatabaseSourceConfig. It is created in the active tenant; connections are tenant-scoped and are not shared across tenants. list#DatabaseSourceConfigs and delete#DatabaseSourceConfig read and remove saved connections. A delete is refused while saved queries still use the connection. Otherwise it moves the connection to the bin for your tenant’s bin window (14 days by default), where it answers “not found” to every read. restore#DatabaseSourceConfig brings it back (owner only), and list#DatabaseSourceConfigs with includeArchived lists binned connections too. When the window ends, Darpan deletes it.
1

Describe the server

2

Set the TLS posture

requireTls is Y by default. Leave it on unless the server cannot offer TLS.With TLS on, Darpan verifies the server’s certificate and hostname, not only that the connection is encrypted. It trusts the public certificate authorities, AWS RDS included, so a managed database with a public certificate needs nothing more.If the server’s certificate is signed by a private authority, pass that authority’s certificate in PEM form as caCertPem. Darpan then verifies the server against that certificate instead of the public authorities.
Verification applies to connections saved before it shipped too. A connection whose certificate cannot be verified stops connecting until its CA is stored as caCertPem.
3

Set the limits

Max rows is a hard cap, not a page size. A query that returns more rows than the cap fails the extraction — it never silently truncates. That is deliberate: a reconciliation run against a quietly truncated source reports differences that are artefacts of the truncation, and nothing on the result would tell you. If you hit the cap, narrow the query rather than raising the number.
4

Check the connection

Once saved, the connection is covered by the standard connection diagnostics (facade.SettingsFacadeServices.test#SourceConnection), which connect and run the dialect’s test query. A credential that expires later shows up as a failed check rather than as a failed run.

Write the query

A query belongs to a connection and holds the SELECT that produces the records to compare. Save it with facade.DatabaseFacadeServices.save#DatabaseSourceQuery, passing the databaseSourceConfigId and the statement as sqlSelect. The statement is validated before it is stored. list#DatabaseSourceQueries and delete#DatabaseSourceQuery read and remove saved queries.
1

Write a single SELECT

The statement must be a single SELECT, or a WITH … SELECT, with no semicolons. Nothing else is accepted.Return the fields you intend to reconcile, named as you want them to appear. Column names become the field names Darpan compares on, so alias them into the shape your schema expects rather than reshaping later.
2

Add the window placeholders, if the query is time-bounded

A query may use the named placeholders :windowStart and :windowEnd. Darpan fills them with the run’s window. Both are optional — a query that reconciles a full table needs neither. Any other :name placeholder is rejected when the query is validated.Use them for anything scheduled. A query with no window re-reads the whole table on every run, which gets slower as the table grows and usually compares far more than the run needs.
3

Preview it

facade.DatabaseFacadeServices.preview#DatabaseQuery runs the query capped at 10 rows, with a 30-second timeout, and returns the columns and rows. Without a window, the preview reads the last 7 days. Check the column names and a few values before saving: the preview is where a wrong alias or an unexpected null is cheap to notice.

Use it in a run

A run side reads from a database when its source has sourceConfigType DATABASE_QUERY and the saved query’s databaseSourceQueryId as its sourceConfigId. Ask an operator to set that up. Both sides of a run may be database sources, for example two instances with the same schema and a different SELECT per side. From there it behaves like any other API-backed source: it runs on the automation’s date window, and the window fills :windowStart and :windowEnd. Because the query fixes the field names, a flat schema matching those column names is usually the right pairing. Create a schema can infer one from a CSV sample of the same shape if you have one.

Expected result

The connection passes its diagnostics check, the query previews the rows you expect with the names you expect, and a run that points at the query extracts those rows.

Troubleshooting

For the exact error messages, see Connections troubleshooting. See Set up a reconciliation run for pairing the source into a run, and Create a schema for the schema it needs.