Connect to SQL and NoSQL Databases
What is a connection?
A connection links your databases to fidesops, so you can gather and update selected PII categories.
Supported databases
Fidesops supports connections to the following databases:
- PostgreSQL
- MongoDB
- MySQL
- MariaDB
- Microsoft SQLServer
- Amazon Redshift
- Snowflake
- Google BigQuery
- Timescale DB
Other platforms will be added in future releases.
Create a ConnectionConfig object
The connection between fidesops and your database is represented by a ConnectionConfig object. To create a ConnectionConfig, you issue a request to the Create a ConnectionConfig operation, passing a payload that contains the properties listed below.
-
nameis a human-readable name for your database. -
keyis a string token that uniquely identifies your ConnectionConfig object. If you don't supply akey, thenamevalue, converted to snake-case, is used. For example, if thenameisApplication PostgreSQL DB, the converted key isapplication_postgresql_db. -
connection-typespecifies the type of database. Valid values arepostgres,mongodb,mysql,mariadb,mssql,redshift,snowflake, andbigquery. -
accesssets the connection's permissions, one of "read" (fidesops may only read from your database) or "write" (fidesops can read from and write to your database). -
disableddetermines whether the ConnectionConfig is active. If True, we skip running queries for any collection associated with that ConnectionConfig. -
descriptionis an extra field to add further details about your connection.
While the ConnectionConfig object contains meta information about the database, you'll notice that it doesn't actually identify the database itself. We'll get to that when we set the ConnectionConfig's "secrets".
PostgreSQL
PATCH api/v1/connection | |
|---|---|
1 2 3 4 5 6 7 8 | |
MongoDB
PATCH api/v1/connection | |
|---|---|
1 2 3 4 5 6 7 8 9 | |
MySQL
PATCH api/v1/connection | |
|---|---|
1 2 3 4 5 6 7 8 9 | |
MariaDB
PATCH api/v1/connection | |
|---|---|
1 2 3 4 5 6 7 8 9 | |
MsSQL
PATCH api/v1/connection | |
|---|---|
1 2 3 4 5 6 7 8 9 | |
Manual connections
PATCH api/v1/connection | |
|---|---|
1 2 3 4 5 6 7 8 9 10 | |
TimescaleDB
PATCH api/v1/connection | |
|---|---|
1 2 3 4 5 6 7 8 9 | |
Set ConnectionConfig secrets
After you create a ConnectionConfig, you explain how to connect to it by setting its "secrets": host, port, user, and password (note that the secrets used are specific to the DB connector). You do this by creating a ConnectionConfig Secrets object by calling the Set a ConnectionConfig's Secrets operation. You can set the object's attributes separately, or supply a single url string that encodes them all.
If you set the verify query parameter to true, the operation will test the connection by issuing a trivial request to the database. The test_status response property announces the success of the connection attempt as succeeded or failed. If the attempt has failed, the failure_reason property gives further details about the failure.
To skip the connection test, set verify to false.
Note: fidesops encrypts all ConnectionConfig secrets values before they're stored.
Set the secrets separately
This example sets the database secrets through separate properties and then tests the connection.
PUT /api/v1/connection/application-postgresql-db/secret?verify=true | |
|---|---|
1 2 3 4 5 6 7 | |
Set the secrets as a URL
This example sets the database secrets as a single url property, and skips the connection test.
PUT api/v1/connection/my_mongo_db/secret?verify=false | |
|---|---|
1 2 3 | |
Amazon Redshift
This Amazon Redshift example sets the database secrets as a url property and a db_schema property. Redshift
databases have one or more schemas, with the default being named public. If you need to set a different schema,
specify db_schema for Redshift, and it will be set as the search_path when querying.
PUT api/v1/connection/my_redshift_db/secret | |
|---|---|
1 2 3 4 | |
Google BigQuery
For Google BigQuery, there are 2 items needed for secrets:
dataset - Name of your dataset. BigQuery datasets are top-level containers (within a project) that are used to organize and control access to your tables and views.
keyfile_creds - Credentials from your service account JSON keyfile, accessible for download from the GCP console.
Here's an example of what this looks like:
PUT api/v1/connection/my_bigquery_db/secret | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
Test your connection
You can verify that a ConnectionConfig's secrets are valid at any time by calling the Test a ConnectionConfig's Secrets operation:
1 | |
Once again, the test_status and failure_reason properties describe the success or failure of the test. If the test failed,
you should adjust the ConnectionConfig Secrets properties through additional calls to Set a ConnectionConfig's Secrets
Connection succeeded
1 2 3 4 5 | |
Connection failed
1 2 3 4 5 | |
Associate a Dataset
Once you have a working ConnectionConfig, it can be associated to an existing dataset by calling the /dataset endpoint, with a JSON version of your dataset as the request body:
PATCH /api/v1/connection/my_connection_key/dataset | |
|---|---|
1 2 3 4 5 6 | |
Filtering ConnectionConfigs
Current available filters are the connection_type and whether the connection is disabled.
Connection type filter
Including multiple connection_type query params and values will result in a query that looks for
any connections with that type.
GET api/v1//connection/?connection_type=mariadb&connection_type=postgres | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
Disabled filter
The disabled filter can show which datastores are skipped as part of privacy request execution.
GET api/v1/connection/?disabled=true | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
Testing_Status filter
The testing_status filter queries on the status of the last successful test:
GET api/v1/connection/?test_status=false | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
System_Status filter
The system_status filter surfaces either database or saas-type connectors:
GET api/v1/connection/?system_type=database | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
Search a ConnectionConfig
You can search the name, key, and description fields of your ConnectionConfigs with the search query parameter.
GET /api/v1/connection/?search=application mysql | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
How do ConnectionConfigs differ from Datasets?
A Dataset is an annotation of your database schema; it describes the PII category (or Data Categories) for each field that the database contains. A ConnectionConfig holds the secrets to connect to the database. Each Dataset has a foreign key to a ConnectionConfig.
After fidesops connects to your database, it generates valid queries by consulting the annotations in the Dataset.
Here is an example of how a "person" table in your PostgreSQL database might map to a fidesops Dataset:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
See Configuring Datasets for more information.