Core (irides_core / core.db_connector)
Shared Python library used by the CLI, API, and Worker. It provides the public Catalog facade, database connector abstractions, Pydantic models, optional Redis cache management, configuration loading, metadata persistence, project manifest validation, and the async job store.
Both import irides_core and import core.db_connector are supported.
Package Structure
core/db_connector/
├── connectors/ # DB-specific connector implementations
│ ├── mysql.py
│ ├── postgres.py
│ ├── sqlite.py
│ ├── duckdb.py
│ ├── dynamodb.py
│ ├── mongodb.py
│ ├── athena.py
│ ├── trino.py
│ └── presto.py
├── exporting/ # Multi-format artifact exporting (Markdown, OKF)
│ ├── __init__.py
│ ├── models.py # ExportFormat, ExportOptions
│ ├── preformatters.py # essential_record deterministic view
│ ├── markdown.py # Markdown table renderer
│ ├── okf.py # Open Knowledge Format (OKF v0.2) renderer
│ └── artifact_store.py # FileArtifactStore (atomic write, 0644, bundle index)
├── models/ # Pydantic data models
│ ├── instance.py
│ ├── schema.py
│ ├── table.py
│ ├── column.py
│ ├── table_details.py # TableDescription, PrimaryKey, ForeignKey, Index, Partition
│ └── scan_job.py # ScanJob, ScanScope, ScanStatus
├── interface.py # BaseConnector abstract class
├── manager.py # ConnectorManager (auto-discovers BaseConnector implementations)
├── cache_manager.py # Redis cache (get/set with prefix + TTL)
├── config_service.py # ConfigService — resolves configs & instances to connectors
├── configurations.py # DB configuration loading from environment variables
├── storage.py # Metadata persistence (BaseMetadataStore + FileMetadataStore)
└── job_store.py # JobStore — Redis Stream queue + job metadata & result storage
Key Modules
exporting/
Provides multi-format artifact exporting decoupled from raw JSON storage.
ExportFormat: Enum supportingmarkdownandokf(Open Knowledge Format v0.2). Both are generated by default.ExportOptions: Controls derived artifact generation (formats: list[ExportFormat],preformat: bool = True). Supports explicit opt-out.preformatters.py(essential_record): Deterministic view preserving identity, summary, columns, keys, relations, unique non-primary indexes, partitions, owner, tags, and status. Excludes non-unique secondary indexes and verbose internal metadata to optimize token usage.markdown.py(render_markdown): Generates structured Markdown tables, keys, relationships, indexes, and partitions. Used both for standalone Markdown output and the OKF document body.okf.py(render_okf): Renders OKF v0.2 documents with YAML frontmatter (type: Database Table, title, description, tags, generator metadata, identifiers) followed by the Markdown body.artifact_store.py(FileArtifactStore): Persists artifacts toSTORAGE_EXPORT_DIRvia atomic writes with readable0644file permissions, maintaining separate directory hierarchies for Markdown and OKF catalog bundles with an auto-updatedindex.md:
storage/
metadata/
{config}/{instance}/{schema}/{table}.json
exports/
markdown/
{config}/{instance}/{schema}/{table}.md
okf/
catalog/
index.md
{config}/{instance}/{schema}/{table}.md
storage.py
Provides metadata persistence abstractions.
BaseMetadataStore — abstract interface with these methods:
| Method | Description |
|---|---|
save_table_metadata(...) |
Write or update a table metadata document and derived exports |
get_table_metadata(...) |
Read a stored document by config+instance+schema+table |
list_instances(page, page_size) |
Paginated list of all stored instance names |
list_databases(instance_name, page, page_size) |
Paginated list of databases for an instance |
list_tables_metadata(instance_name, database_name, page, page_size) |
Paginated list of table names |
find_table_metadata(instance_name, database_name, table_name) |
Look up a table across all configs |
update_table_metadata(instance_name, database_name, table_name, payload) |
Merge custom fields into a stored document and regenerate exports |
FileMetadataStore (default) — saves canonical JSON documents under STORAGE_METADATA_DIR and derived exports under STORAGE_EXPORT_DIR.
Key behaviours:
- Decoupled export pipeline: Derived artifacts (Markdown, OKF) are generated independently from JSON metadata persistence. Setting
save_metadata=Falsestill generates exports if requested. - Automatic export regeneration: Calling
update_table_metadatato merge human annotations automatically regenerates the corresponding Markdown and OKF documents. - Custom field carry-forward: any key not in
_SYSTEM_KEYS(metadata_key,config_name,instance_name,schema_name,table_name,updated_at,schema_description,ai_documentation) is preserved across re-describe calls. Human-added fields such asowner,tags, andnotessurvive schema refreshes. only_if_changed: whenTrue,save_table_metadataskips the JSON write ifschema_descriptionis identical to the stored version, leavingupdated_atand human annotations untouched, but exports the current state.ai_documentationpreservation: ifai_documentation=Noneis passed, the existing stored AI doc is kept rather than overwritten.- Protected fields:
update_table_metadatasilently ignoresmetadata_key,config_name,instance_name,schema_name,table_name, andupdated_atin the payload — these are always managed by the system.
Paginated list responses follow this envelope:
{
"items": ["name_a", "name_b"],
"total": 2,
"page": 1,
"page_size": 20,
"pages": 1
}
Use get_metadata_store() (factory function) to obtain the configured store. Set METADATA_STORE_TYPE=file (default) or extend with future backends (s3, athena).
ai_service.py
AIDocumentationService: Non-blocking integration with LiteLLM (LITELLM_MODEL, default gpt-4o-mini). Generates high-level domain summaries and column descriptions. When requested, generated docs are attached to TableDescription.ai_documentation with ai_generation_status; failures also include ai_generation_error. If litellm is uninstalled, API keys are missing, or network errors occur, it logs a warning and returns no documentation without throwing exceptions.
configurations.py
Reads database connection parameters from environment variables. DB_TARGETS supports any number of named targets for any connector.
- Supports
DB_CONFIG_FILEenvironment variable to explicitly specify the path to a container.envfile (e.g./app/api/.env), falling back to defaultload_dotenv()discovery when unset. - Target names from
DB_TARGETSbecome API/MCPconfig_namevalues. Example:DB_TARGETS=sales_mysql,analytics_pgcreatessales_mysqlandanalytics_pgconfigurations. - Each target uses
DB_TARGET_<TARGET_KEY>_*variables, where<TARGET_KEY>is the uppercased target name with non-alphanumeric characters replaced by underscores. - Exact required and optional keys for each connector type are documented in the root README under DB Configuration & Activation.
config_service.py
Wraps ConnectorManager and configurations.
list_instances(config_name, no_cache): Uniformly lists instances for both multi-host configurations (MySQL/MariaDB) and flat configurations (Athena, DynamoDB, Trino, MongoDB, SQLite).resolve_instance_names(config_name, instance_name, no_cache): Returns[instance_name]if specified, or all discovered instances ifinstance_nameisNone._get_hosts(config_name): Returns explicitly configured hosts, correctly recognizing both multi-hosthostscollections and flathostparameters.configuration_matches_instance(config_name, instance_name, no_cache): Checks whether an instance belongs to a given configuration.resolve_configurations_for_instance(instance_name, no_cache): Centralized lookup returning all configuration names matching a target instance._get_connector_for_host(config_name, host): Returns the connector for a specific host, falling back to flat connection parameters when static host definitions are omitted.
cache_manager.py
Redis-backed cache for introspection results. All keys are prefixed with CACHE_KEY_PREFIX. Cache can be bypassed per-call with no_cache=True.
job_store.py
Manages async scan jobs via Redis:
- Stream (
{prefix}:scan:queue) — job queue for workers (scan-workersconsumer group). Stream messages serializeexport_formatsandexport_preformatparameters. - Hash (
{prefix}:scan:job:{job_id}) — job metadata, scope, and status. Supports deserialization of new export options with backwards compatibility for legacy jobs withsave_markdown. - List (
{prefix}:scan:results:{job_id}) — serializedTableDescriptionresults with automatic TTL extensions on writes. - Sorted Set (
{prefix}:scan:jobs) — job index ordered by creation timestamp, automatically pruned of entries older thanRESULTS_TTLviazremrangebyscoreto prevent Redis memory leaks.
Supported Databases
| Database | Connector Type | Configuration Style |
|---|---|---|
| MySQL / MariaDB | mysql |
Named DB_TARGETS |
| PostgreSQL | postgres |
Named DB_TARGETS |
| SQLite | sqlite |
Named DB_TARGETS |
| DuckDB | duckdb |
Named DB_TARGETS |
| Amazon DynamoDB | dynamodb |
Named DB_TARGETS |
| Amazon Athena | athena |
Named DB_TARGETS |
| MongoDB | mongodb |
Named DB_TARGETS |
| Trino | trino |
Named DB_TARGETS |
| Presto | presto |
Named DB_TARGETS |
Environment Variables
Copy .env.example to .env and configure as needed.
| Variable | Default | Description |
|---|---|---|
REDIS_HOST |
localhost |
Redis host |
REDIS_PORT |
6379 |
Redis port |
REDIS_DB |
0 |
Redis database index |
REDIS_TTL_SECONDS |
86400 |
Introspection cache TTL (1 day) |
CACHE_KEY_PREFIX |
irides |
Prefix for all Redis keys |
SCAN_RESULTS_TTL_SECONDS |
604800 |
Scan result retention in Redis (7 days) |
DB_CONFIG_FILE |
(none) | Explicit path to .env configuration file |
DB_TARGETS |
(none) | Comma-separated list of named DB targets |
STORAGE_METADATA_DIR |
storage/metadata |
Metadata JSON output directory |
STORAGE_EXPORT_DIR |
storage/exports |
Directory for generated Markdown and OKF exports |
METADATA_STORE_TYPE |
file |
Metadata store backend (file; s3/athena planned) |
LITELLM_MODEL |
gpt-4o-mini |
LiteLLM model for AI documentation |
LITELLM_API_KEY |
(none) | Optional provider API key override |
LITELLM_API_BASE |
(none) | Optional custom LiteLLM API base URL |
DB activation vars — see root README.
Installation
The core package is installed in editable mode by the API and Worker:
pip install -e /path/to/core
# or via requirements.txt:
pip install -r requirements.txt
Adding a New Connector
- Create
core/db_connector/connectors/mydb.pyimplementingBaseConnector. - Export it from
core/db_connector/connectors/__init__.py. - Add its activation env var and config block to
core/db_connector/configurations.py.
The ConnectorManager automatically discovers all classes that extend BaseConnector.
Metadata
Release files for irides-core 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| irides_core-0.1.4.tar.gz | 64.9 kB | Without provenance | Details for irides_core-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| irides_core-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for irides_core-0.1.4-py3-none-any.whl |
Total release size: 143.2 kB
Release files / irides_core-0.1.4.tar.gz
| Download URL | irides_core-0.1.4.tar.gz |
|---|---|
| Size | 64.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b1d16bb6a219efa922a0b1c0ff3bcc8ebae4f6972c3e55506c42f238968725de
|
|
BLAKE2b-256 checksum How to use checksums |
299d7bc06e1072b0be1d736a72c897c2dfb8e1c15af2968e0b23d59bde061394
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|
Release files / irides_core-0.1.4-py3-none-any.whl
| Download URL | irides_core-0.1.4-py3-none-any.whl |
|---|---|
| Size | 78.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f3597b59be9f69e8b1e63aa92b427831c9128127a5546e2dcfcfe8ba10d5c715
|
|
BLAKE2b-256 checksum How to use checksums |
3386ca788ba5ff4b477db706a68cbd190c36929a1b99e9e38f1989bc52481ae9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|
Security for irides-core 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.