Soda Core PostgreSQL
raw JSON → 3.5.6 verified Fri May 01 auth: no python
Extends Soda Core to connect to PostgreSQL databases for data quality monitoring and testing. Current version 3.5.6, released on 2025-11-05. Release cadence is irregular, tied to soda-core releases.
pip install soda-core-postgres Common errors
error soda.core.exceptions.DataSourceConnectionError: Unable to connect to PostgreSQL: could not adapt type 'NoneType' ↓
cause Password or other variable is None because environment variable is not set.
fix
Ensure all required environment variables (e.g., POSTGRES_PASSWORD) are set before calling scan.execute().
error soda.scan.SodaScanError: The given data source name 'postgres' is not configured. Available data sources: [] ↓
cause The data source name in the configuration does not match the name used in set_data_source_name().
fix
Ensure both the YAML key (after 'data_source') and the argument to set_data_source_name() are identical and lowercase.
error ModuleNotFoundError: No module named 'psycopg2' ↓
cause The PostgreSQL driver is not installed.
fix
Install psycopg2-binary: pip install psycopg2-binary
Warnings
gotcha The configuration file must use 'type: postgres' exactly. Using 'postgresql' or other variants will fail silently. ↓
fix Use 'type: postgres' in the YAML configuration.
gotcha Soda Core requires the PostgreSQL driver (psycopg2 or asyncpg) to be installed separately. soda-core-postgres does not install it automatically. ↓
fix Run 'pip install psycopg2-binary' or 'pip install asyncpg' in the same environment.
gotcha The 'data_source' key in YAML must be lowercase; using 'data_source: Postgres' (capitalized) will be ignored. ↓
fix Write 'data_source postgres:' exactly as lower_snake_case.
Imports
- Scan
from soda.scan import Scan
Quickstart
from soda.scan import Scan
scan = Scan()
scan.set_scan_definition_name('test')
scan.set_data_source_name('postgres')
scan.add_configuration_yaml_str('''
data_source postgres:
type: postgres
host: localhost
port: 5432
username: ${POSTGRES_USER}
password: ${POSTGRES_PASSWORD}
database: postgres
''')
scan.add_sodacl_yaml_str('''
checks for dim_customer:
- row_count > 0
''')
exit_code = scan.execute()
print(scan.get_logs_text())