Skip to main content

PostgreSQL and MySQL

Datafi connects to PostgreSQL and MySQL through native database drivers powered by the sqlx library. This provides high-performance, type-safe connectivity with support for password authentication, SSL/TLS encryption, and built-in connection pooling.


Supported Versions

DatabaseSupported VersionsDriver
PostgreSQL12, 13, 14, 15, 16sqlx (native Rust driver)
MySQL5.7, 8.0, 8.1, 8.2sqlx (native Rust driver)
note

Datafi also supports PostgreSQL-compatible databases such as Amazon Aurora PostgreSQL, Azure Database for PostgreSQL, and Google Cloud SQL for PostgreSQL. MySQL-compatible databases like Amazon Aurora MySQL and Azure Database for MySQL are also supported.


Authentication

Password Authentication

The simplest connection method. Provide a username and password that Datafi uses to authenticate with your database server.

ParameterDescriptionRequired
HostThe hostname or IP address of your database server.Yes
PortThe port number (PostgreSQL default: 5432, MySQL default: 3306).Yes
DatabaseThe name of the database to connect to.Yes
UsernameThe database user account.Yes
PasswordThe password for the user account.Yes

SSL/TLS Authentication

For production environments, you should enable SSL/TLS to encrypt data in transit between the Edge node and your database.

SSL ParameterDescriptionRequired
SSL ModeThe level of SSL enforcement (see table below).Yes
CA CertificateThe root certificate authority certificate file (PEM format).Depends on mode
Client CertificateThe client certificate file for mutual TLS.Optional
Client KeyThe private key file corresponding to the client certificate.Optional

SSL Modes:

ModeEncryptionServer VerificationClient Certificate
disableNoNoNo
preferIf availableNoNo
requireYesNoNo
verify-caYesCA validatedNo
verify-fullYesCA + hostname validatedNo
mutualYesCA + hostname validatedYes
warning

Using disable or prefer modes in production is strongly discouraged. At minimum, use require to ensure all traffic between the Edge node and your database is encrypted.


Setting Up a Connection

  1. Navigate to Integrations > Add Data Source.
  2. Select PostgreSQL or MySQL from the connector list.
  3. Enter the connection parameters (host, port, database, credentials).
  4. Optionally configure SSL by uploading certificates.
  5. Click Test Connection to verify connectivity.
  6. Click Save to add the data source.

Once saved, Datafi runs schema introspection to catalog tables, views, columns, and data types. The source appears in your Data Catalog within a few minutes.


Connection Pooling

Datafi maintains a connection pool for each configured data source to optimize performance and manage database connections efficiently. The pool is managed at the Edge node level.

Pool ParameterDescriptionDefault
Min ConnectionsThe minimum number of idle connections maintained in the pool.2
Max ConnectionsThe maximum number of concurrent connections allowed.10
Idle TimeoutDuration (in seconds) before an idle connection is closed.300
Max LifetimeMaximum duration (in seconds) a connection can remain open.1800
Acquire TimeoutMaximum wait time (in seconds) to acquire a connection from the pool.30

To adjust pool settings:

  1. Navigate to the data source configuration in Integrations.
  2. Open the Advanced tab.
  3. Modify pool parameters.
  4. Click Save. Changes take effect for new connections.
tip

If you see connection pool exhausted errors in the connector log, increase the Max Connections value. Ensure your database server also allows enough concurrent connections to accommodate the pool size.


Query Execution

When you query a PostgreSQL or MySQL source, Datafi compiles the request to the appropriate SQL dialect.

FeaturePostgreSQLMySQL
CTEsSupportedSupported (8.0+)
Window FunctionsSupportedSupported (8.0+)
JSON Functionsjsonb_* functionsJSON_* functions
LIMIT/OFFSETSupportedSupported
Prepared StatementsSupportedSupported

The native driver handles type mapping automatically. PostgreSQL-specific types (e.g., JSONB, UUID, ARRAY) and MySQL-specific types (e.g., ENUM, SET) are mapped to Datafi's internal type system.


Troubleshooting

IssuePossible CauseResolution
Connection refusedFirewall blocking the port or database not listening on the specified host.Verify network access from the Edge node to the database server.
SSL certificate verify failedCA certificate mismatch or expired certificate.Upload the correct CA certificate or renew expired certificates.
Too many connectionsPool size exceeds database max_connections.Reduce Datafi pool size or increase the database limit.
Authentication failedIncorrect username or password.Verify credentials and check database authentication logs.

Next Steps

  • Snowflake -- Connect to Snowflake with JWT or OAuth.
  • Cloud Warehouses -- Set up BigQuery, Databricks, Redshift, or Synapse.