What Database Integrations Does OpenSRE Support? A Complete Guide to Built-In Connectors

OpenSRE supports seven production-grade database integrations including PostgreSQL, MySQL, MariaDB, MongoDB (self-hosted), MongoDB Atlas, ClickHouse, and Azure SQL, each implemented with automatic configuration discovery and validation.

OpenSRE is an open-source platform designed to streamline reliability engineering workflows by providing standardized integrations with critical infrastructure components. The database integrations are a core capability of the project, enabling automatic discovery, configuration validation, and health monitoring across diverse data stores. Each integration follows a consistent architectural pattern defined in the app/integrations/ directory, ensuring predictable behavior whether you are connecting to a self-hosted PostgreSQL instance or a managed MongoDB Atlas cluster.

Supported Database Integrations in OpenSRE

OpenSRE ships with dedicated integration modules for seven major database systems. Each module resides in its own Python file under app/integrations/ and exposes standardized configuration builders, environment variable parsers, and validation routines.

PostgreSQL

The PostgreSQL integration handles connections to self-hosted or managed PostgreSQL instances. According to the OpenSRE source code, the integration is implemented in app/integrations/postgresql.py and provides the following core functions:

  • build_postgresql_config() – Constructs a strongly-typed configuration object from raw parameters
  • postgresql_config_from_env() – Parses environment variables (e.g., POSTGRESQL_HOST, POSTGRESQL_DATABASE, POSTGRESQL_PORT, POSTGRESQL_USERNAME, POSTGRESQL_PASSWORD, POSTGRESQL_SSL_MODE) into a config object
  • resolve_postgresql_config() – Resolves final configuration from mixed sources
  • validate_postgresql_config() – Returns a ValidationResult describing connection health or configuration errors

MySQL

MySQL support is provided through app/integrations/mysql.py. The integration follows the same pattern as PostgreSQL with database-specific configuration parameters:

  • build_mysql_config(), mysql_config_from_env(), resolve_mysql_config(), and validate_mysql_config() handle the full lifecycle of configuration management
  • Environment variables use the MYSQL_ prefix for host, database, port, username, and password settings

MariaDB

MariaDB integration is implemented separately in app/integrations/mariadb.py despite its similarity to MySQL, ensuring explicit compatibility checks and dedicated configuration namespaces:

  • build_mariadb_config(), mariadb_config_from_env(), resolve_mariadb_config(), and validate_mariadb_config() provide the standard interface
  • Uses MARIADB_ prefixed environment variables to avoid conflicts with MySQL settings

MongoDB (Self-Hosted)

The self-hosted MongoDB integration in app/integrations/mongodb.py supports standalone instances and replica sets without Atlas-specific features:

  • build_mongodb_config(), mongodb_config_from_env(), and validate_mongodb_config() manage connection string construction and credential handling
  • Validates connection parameters before attempting client initialization

MongoDB Atlas

MongoDB Atlas is treated as a distinct integration in app/integrations/mongodb_atlas.py to handle Atlas-specific connection strings, cluster tiers, and managed security features:

  • build_mongodb_atlas_config(), mongodb_atlas_config_from_env(), and validate_mongodb_atlas_config() implement the standard pattern with Atlas-specific parameter validation
  • Distinguishes between Atlas dedicated clusters and serverless instances during configuration resolution

ClickHouse

ClickHouse column-store support is provided through app/integrations/clickhouse.py, enabling high-performance analytical queries:

  • build_clickhouse_config(), clickhouse_config_from_env(), and validate_clickhouse_config() handle HTTP and native protocol configurations
  • Supports validation of secure connection parameters and custom HTTP headers

Azure SQL

Azure SQL Database and Azure SQL Managed Instance are supported via app/integrations/azure_sql.py, including Active Directory authentication options:

  • build_azure_sql_config(), azure_sql_config_from_env(), resolve_azure_sql_config(), and validate_azure_sql_config() implement the standard interface
  • Handles Azure-specific connection string formats and token-based authentication flows

How OpenSRE Database Integrations Work

OpenSRE employs a consistent architectural pattern across all database integrations to ensure predictable behavior and maintainable code.

Configuration Discovery and Resolution

Each integration provides three configuration helpers that form a pipeline from raw input to validated config:

  1. build_<db>_config – Accepts explicit parameters (host, port, credentials) and returns a strongly-typed Pydantic model defined in app/integrations/models.py
  2. <db>_config_from_env – Loads configuration from environment variables using the database-specific prefix (e.g., POSTGRESQL_, MYSQL_)
  3. resolve_<db>_config – Merges environment variables with explicit arguments, with explicit parameters taking precedence

Validation and Health Checking

The validate_<db>_config function in each module performs deep connection validation:

  • Returns a ValidationResult object indicating success or specific failure modes (authentication errors, network timeouts, SSL handshake failures)
  • Performs lightweight connection tests without executing destructive operations
  • Catches configuration errors early before expensive client initialization

Unified Verification Flow

The app/integrations/verify.py module provides the verify_integrations function that orchestrates health checks across all registered databases:

from app.integrations.verify import verify_integrations

results = verify_integrations(service="postgresql")  # Filter by specific DB

for r in results:
    print(f"{r['service']} – available: {r['available']}")

This routine:

  • Imports all integration modules dynamically
  • Invokes is_configured methods to check for environment presence
  • Runs validate_<db>_config for configured services
  • Returns a standardized JSON-serializable list suitable for CLI output, web UI dashboards, and automated testing

Working with Database Integrations: Practical Examples

The following examples demonstrate common patterns for configuring and validating OpenSRE database integrations in production environments.

Configuring PostgreSQL via Environment Variables

Create a .env file or export variables in your shell:

POSTGRESQL_HOST=pg.example.com
POSTGRESQL_DATABASE=mydb
POSTGRESQL_PORT=5432
POSTGRESQL_USERNAME=app_user
POSTGRESQL_PASSWORD=secure_password
POSTGRESQL_SSL_MODE=require

Then load the configuration in Python:

from app.integrations.postgresql import postgresql_config_from_env

cfg = postgresql_config_from_env()

# cfg is a PostgreSQLConfig dataclass ready for consumption

Resolving MySQL Configuration from Mixed Sources

When you need to override environment defaults with explicit parameters:

from app.integrations.mysql import resolve_mysql_config

raw = {"host": "db.example.com", "database": "sales", "port": 3306}
cfg = resolve_mysql_config(**raw)   # returns MySQLConfig

# Explicit parameters take precedence over environment variables

Running Health Checks Across All Databases

To verify which integrations are properly configured and accessible:

from app.integrations.verify import verify_integrations

results = verify_integrations()
for r in results:
    status = "✓" if r['available'] else "✗"
    print(f"{status} {r['service']}: {r.get('details', r.get('error', 'N/A'))}")

Using a Validated ClickHouse Client

After validation, instantiate the database-specific client:

from app.integrations.clickhouse import ClickHouseClient, clickhouse_config_from_env

cfg = clickhouse_config_from_env()
if cfg:
    client = ClickHouseClient(cfg)
    result = client.run_query("SELECT count() FROM events")
    print(f"Event count: {result}")

Summary

OpenSRE provides comprehensive out-of-the-box support for seven major database systems through a unified integration architecture:

  • Relational databases: PostgreSQL, MySQL, MariaDB, and Azure SQL with full SSL and authentication support
  • Document stores: MongoDB (self-hosted) and MongoDB Atlas with distinct handling for managed cluster configurations
  • Columnar analytics: ClickHouse optimized for high-performance analytical workloads

Each integration in app/integrations/ implements standardized configuration helpers (build_<db>_config, <db>_config_from_env, resolve_<db>_config), validation routines (validate_<db>_config), and health checking through the unified verify_integrations flow in app/integrations/verify.py. This consistent pattern enables automatic discovery, environment-based configuration, and runtime health validation across all supported data stores.

Frequently Asked Questions

Does OpenSRE require manual configuration for each database integration?

No, OpenSRE automatically discovers and validates database integrations through environment variables. Each integration uses a standardized prefix (e.g., POSTGRESQL_, MYSQL_) to load configuration via functions like postgresql_config_from_env() or mysql_config_from_env(). The verify_integrations() routine in app/integrations/verify.py automatically checks all registered integrations without requiring manual enablement.

Can I use both MongoDB self-hosted and MongoDB Atlas simultaneously?

Yes, OpenSRE treats these as distinct integrations. The app/integrations/mongodb.py module handles self-hosted instances and replica sets, while app/integrations/mongodb_atlas.py manages Atlas-specific connection strings and cluster configurations. Each has separate environment variable prefixes and validation logic, allowing you to configure both within the same OpenSRE deployment.

How does OpenSRE validate database connections without exposing credentials?

OpenSRE uses the validate_<db>_config functions (such as validate_postgresql_config or validate_clickhouse_config) to perform lightweight connection tests that verify authentication and network connectivity without executing destructive operations. These functions return ValidationResult objects defined in app/integrations/models.py, which indicate success or specific failure modes (like SSL handshake errors or authentication failures) without logging sensitive credential values.

What is the difference between build_<db>_config and resolve_<db>_config?

The build_<db>_config function (e.g., build_postgresql_config) creates a strongly-typed configuration object from explicit parameters passed as arguments. In contrast, resolve_<db>_config (e.g., resolve_postgresql_config) merges environment variables with any explicit parameters, with explicit arguments taking precedence. This allows flexible configuration management where you can override environment defaults programmatically when needed.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →