Skip to main content

SQLAlchemy-based models, validation, and utilities for the OHDSI OMOP Common Data Model

Project description

OMOP Alchemy

OMOP Alchemy provides a canonical, typed, SQLAlchemy-first representation of the OHDSI OMOP Common Data Model (CDM).

It is designed to support research-ready analytics, validation, and exploration of OMOP data using modern Python tooling, without imposing ETL conventions or execution-time side effects.


Design goals

OMOP Alchemy is intentionally:

  • Declarative
    Defines tables, columns, relationships, and constraints

  • SQLAlchemy-native
    Built for SQLAlchemy 2.x ORM usage

  • Safe to import anywhere
    No implicit engine creation, no global state, no environment assumptions.

  • Typed and inspectable
    Models are fully typed and introspectable for validation, tooling, and IDE support.

  • Backend-agnostic
    Designed to work across PostgreSQL, SQLite, and other SQLAlchemy-supported databases.


What this package does not do

OMOP Alchemy deliberately avoids:

  • Enforcing ETL conventions or data pipelines
  • Auto-creating databases or loading vocabularies
  • Imposing analytics frameworks or dashboards
  • Making assumptions about deployment environments

These concerns are intentionally left to downstream tooling.


Core features

  • SQLAlchemy ORM models for OMOP CDM tables
  • Explicit foreign key and relationship definitions
  • Read-only View classes for safe navigation and analytics
  • Domain validation helpers for OMOP concept integrity
  • CSV loading utilities for controlled ingestion and testing
  • Lightweight schema and model validation against CDM specs

Example (concept navigation)

from omop_alchemy.model.vocabulary import ConceptView

concept = session.get(ConceptView, 320128)  # Lung cancer
concept.domain.domain_id        # "Condition"
concept.vocabulary.vocabulary_id  # "SNOMED"
concept.is_standard             # True

Status

This project is currently beta.

The API is stabilising, but some modules may change as real-world use cases expand. Feedback and issues are welcome.

Some additional background

This work builds on earlier research and tooling presented at the 2023 OHDSI APAC Symposium

see background paper.


Configuration

OMOP Alchemy reads all database connection and schema settings from oa-configurator. No .env files or ENGINE environment variables are needed.

Run once after installation:

omop-config init
omop-config configure omop_alchemy

See Configuration for full details.


Docker Compose

The included docker-compose.yaml provides a PostgreSQL database and a Python container with the [postgres] extra pre-installed. Default credentials work out of the box:

docker compose up

The python-alchemy service runs omop-config configure at startup and writes ~/.config/omop/config.toml on the host on first start; subsequent starts skip configuration automatically.

To override credentials, copy .env.example to .env and edit before starting:

cp .env.example .env
docker compose up

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

omop_alchemy-0.7.0.tar.gz (274.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

omop_alchemy-0.7.0-py3-none-any.whl (169.9 kB view details)

Uploaded Python 3

File details

Details for the file omop_alchemy-0.7.0.tar.gz.

File metadata

  • Download URL: omop_alchemy-0.7.0.tar.gz
  • Upload date:
  • Size: 274.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for omop_alchemy-0.7.0.tar.gz
Algorithm Hash digest
SHA256 34bceb5798756d29347b23ed93429ee555393589e49e9d261f325a0ab49505e2
MD5 e23c55509c678ae9ba9a5127c5be6db0
BLAKE2b-256 cfcb232ccd5f7e8c43f1733be36747aaf39e1ccf55ac1fea4ed855c71f2af666

See more details on using hashes here.

Provenance

The following attestation bundles were made for omop_alchemy-0.7.0.tar.gz:

Publisher: python-publish.yml on AustralianCancerDataNetwork/OMOP_Alchemy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file omop_alchemy-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: omop_alchemy-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 169.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for omop_alchemy-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4a0ef901d35c32468d897a5ce50bc9fc2268c29be4519c3418f6201485bbac8e
MD5 05d496409ea59e89a186080e99cd84b9
BLAKE2b-256 aac9049310af85722bd5a255d8d9e9f33ea7ba456bae15991d6c2c98eac2fc07

See more details on using hashes here.

Provenance

The following attestation bundles were made for omop_alchemy-0.7.0-py3-none-any.whl:

Publisher: python-publish.yml on AustralianCancerDataNetwork/OMOP_Alchemy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page