Skip to main content

raxtik-etl ⚡

Documentation Status CI codecov License: AGPL v3 Python >= 3.11

High-performance canonical pharmacovigilance (PV) data engine and packaging toolkit powered by DuckDB and Polars.

raxtik-etl provides canonical schema definitions, multi-version case deduplication algorithms, and self-describing dataset packaging (DuckDB & Parquet) for safety surveillance datasets. It is completely decoupled from source-specific ingestion logic via an extensible Source Adapter Protocol.

👉 Architecture & Design: See Architecture Overview for plugin decoupling and internal pipeline design.


🏛️ Canonical Data Model & Entity Relationships

Every source connector projects raw records into an analytical star-schema architecture:

  • 7 Core Fact Tables: Normalized clinical entities (demo, drug, reac, outc, indi, ther, rpsr).
  • Authoritative Case View (cases): Deduplicates multi-version submissions across reporting periods (case_id / canonical_case_version / fda_date) and computes key safety flags (has_serious_outcome, is_death, is_expedited).
  • 16 Reference Dimensions (_code_*): Embedded lookup tables mapping ISO country codes, ICH E2B(R2/R3) guidelines, and FDA clinical codelists.

Entity Relationships & Composite Keys

Table Entity / Domain Primary Key (Composite) Foreign Key Relationship Description
demo Case Submissions & Demographics primary_id (Root submission table) Patient age in decimal years, weight in kg, sex, country, receipt date.
drug Drug Products & Regimens (primary_id, drug_seq) primary_id → demo.primary_id Reported brand name, active substance, route, form, role code (PS, SS, C, I).
reac Adverse Reactions (primary_id, reported_reaction_term) primary_id → demo.primary_id MedDRA Preferred Terms (PT) describing adverse events.
outc Patient Outcomes (primary_id, outc_code) primary_id → demo.primary_id Clinical outcomes: Death (DE), Hospitalization (HO), Disability (DS), etc.
indi Therapy Indications (primary_id, indi_drug_seq, reported_indication_term) (primary_id, indi_drug_seq) → drug(primary_id, drug_seq) Medical conditions for which medications were prescribed.
ther Therapy Timelines (primary_id, dsg_drug_seq) (primary_id, dsg_drug_seq) → drug(primary_id, drug_seq) Therapy start date, end date, and duration in days.
rpsr Report Sources (primary_id, rpsr_code) primary_id → demo.primary_id Reporting channel: Health Professional (HP), Consumer (CSM), Study (SDY), etc.
cases Authoritative Deduplicated View case_id Derived from demo Precomputed deterministic resolution to latest report version per case_id.

📖 Visual Entity-Relationship Diagram:


🌐 Precompiled Dataset on Hugging Face

All quarterly Bronze packages (2004Q1–present, 25M+ safety reports) and the verified Silver Tier Deduplication Index (21M+ unique cases, live counts in silver/index/manifest.json) are publicly accessible on Hugging Face: 🔗 raxtik-org/faers-safety-database

  • Bronze Tier (bronze/<YEAR>/): Standalone DuckDB databases (.duckdb) and ZSTD Parquet tables (.parquet/).
  • Silver Tier (silver/index/): Append-only ledgers (ledger/), 16-shard immutable base snapshots (state/base/), complete-state deltas (state/deltas/), and active manifest.json.

📦 Installation

pip install raxtik-etl raxtik-source-faers

For developer setup and contributing from source, see CONTRIBUTING.md.


🚀 Quickstart

1. Download or Build via CLI

# Recommended: Download precompiled package directly from Hugging Face Hub (zero auth required)
raxtik-etl download -d 2004Q1

# Inspect package schema and data quality indicators
raxtik-etl inspect -d 2004Q1

# Build a quarterly package locally from raw FDA archives
raxtik-etl build -d 2004Q1 --source faers

👉 CLI Reference: See the full CLI Reference Guide for all commands and parameters.


💻 Python SDK Usage

Load and query precompiled safety packages directly in Python:

from raxtik_etl import FAERS

# 1. Default (Recommended): Downloads once, caches locally, and queries in milliseconds
with FAERS.from_hf("2024Q1") as faers:
    faers.print_summary()
    cases_df = faers.cases(limit=1000)
    drugs_df = faers.drugs(limit=1000)
    reactions_df = faers.reactions(limit=1000)

# 2. Remote Streaming (No Full Dataset Download): Streams over HTTPS directly from Hugging Face
with FAERS.from_hf("2024Q1", remote=True) as faers:
    cases_df = faers.cases(limit=100)
    print(cases_df)

# 3. Quarter-Scoped Silver Tier (winning cases in 2024Q1 as of 2025Q4 + full case timeline)
with FAERS.from_hf("2024Q1", tier="silver", remote=True, as_of_period="2025Q4") as faers:
    cases_df = faers.cases(limit=100)
    timeline = faers.case_timeline(str(cases_df["case_id"][0]))
    print(timeline)

⚡ Remote Querying via DuckDB (No Full Dataset Download)

You can run analytical SQL queries directly against datasets hosted on Hugging Face Hub over HTTPS without downloading full archives to disk. DuckDB's built-in httpfs extension fetches only the metadata and column pages required via HTTP Range requests.

Option A: Remote DuckDB ATTACH (Single File URL, Full Star-Schema & Views)

Points to one single database file containing all 7 fact tables (demo, drug, reac, outc, indi, ther, rpsr), the precomputed cases view, and all 16 reference codelists (_code_*):

import duckdb

con = duckdb.connect()
# httpfs is DuckDB's native C++ extension (no pip install required)
con.execute("INSTALL httpfs; LOAD httpfs;")

# 1 single URL attaches the entire quarterly database
db_url = "https://huggingface.co/datasets/raxtik-org/faers-safety-database/resolve/main/bronze/2024/faers_2024Q1.duckdb"
con.execute(f"ATTACH '{db_url}' AS faers (READ_ONLY);")

# Clean standard SQL joins across tables inside the attached database
con.execute("""
    SELECT
        d.reported_drug_name,
        COUNT(*) AS report_count
    FROM faers.drug d
    JOIN faers.reac r
      ON d.primary_id = r.primary_id
    WHERE d.role_code = 'PS'
      AND r.reported_reaction_term = 'Myocardial infarction'
    GROUP BY d.reported_drug_name
    ORDER BY report_count DESC
    LIMIT 5;
""").show()

Option B: Remote Parquet Scanning (Fast Columnar Range Requests)

Directly queries specific columnar Parquet files, skipping unqueried columns entirely:

import duckdb

con = duckdb.connect()
con.execute("INSTALL httpfs; LOAD httpfs;")

con.execute("""
    SELECT
        d.reported_drug_name,
        COUNT(*) AS report_count
    FROM 'https://huggingface.co/datasets/raxtik-org/faers-safety-database/resolve/main/bronze/2024/faers_2024Q1.parquet/drug.parquet' d
    JOIN 'https://huggingface.co/datasets/raxtik-org/faers-safety-database/resolve/main/bronze/2024/faers_2024Q1.parquet/reac.parquet' r
      ON d.primary_id = r.primary_id
    WHERE d.role_code = 'PS'
      AND r.reported_reaction_term = 'Myocardial infarction'
    GROUP BY d.reported_drug_name
    ORDER BY report_count DESC
    LIMIT 5;
""").show()

🛡️ Data Quality & Cross-Quarter Case Updates

In post-marketing pharmacovigilance surveillance, pharmaceutical manufacturers frequently submit follow-up reports updating therapy durations, additional reactions, or new clinical indications for cases originally reported in previous quarters.

When FDA releases quarterly ASCII snapshots, child tables (drug, reac, indi, ther) occasionally contain update records referencing a primary_id from an earlier quarter without re-emitting the unchanged demographic row:

  • In isolated single-quarter snapshots, this manifests as referential integrity warnings (< 0.0003% of rows, e.g., 5 orphan rows in 2012Q1 and 2026Q3).
  • Rather than silently dropping these clinically valuable update records, raxtik-etl retains them and transparently logs referential warnings during packaging.
  • Multi-quarter cohort consolidation (raxtik-etl consolidate) reconciles multi-version reports into unified case records.

📚 Documentation & Guides


📄 License

Licensed under the GNU Affero General Public License v3.0 (AGPL-3.0). Raw FDA data is in the public domain (US Government Work, 17 U.S.C. § 105). Derived packaged datasets are distributed under the Open Data Commons Attribution License (ODC-By 1.0).

Metadata

Release files for raxtik-etl 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for raxtik-etl 0.1.0
File Size Uploaded Provenance Actions
raxtik_etl-0.1.0.tar.gz 269.0 kB With provenance Details for raxtik_etl-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for raxtik-etl 0.1.0
File Interpreter ABI Platform Actions
raxtik_etl-0.1.0-py3-none-any.whl Python 3 none any Details for raxtik_etl-0.1.0-py3-none-any.whl

Total release size: 391.0 kB

Release files / raxtik_etl-0.1.0.tar.gz

Download URL raxtik_etl-0.1.0.tar.gz
Size 269.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8cfe5e845f9aabfcaa315fec92910bd564ac6a752182c3a335026b55e50adee2
BLAKE2b-256 checksum
How to use checksums
189d15349a937a39cdfd84138036570fb6758eee879cb20e95808208e44b62cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / raxtik_etl-0.1.0-py3-none-any.whl

Download URL raxtik_etl-0.1.0-py3-none-any.whl
Size 121.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8db2f465e21013e427e39e443ab2d0b56e3a2dbc763f02b5223e822cb6dd5a87
BLAKE2b-256 checksum
How to use checksums
0b2db4ee437e470e4f47dead4d8026b626fa0f67ca3bedd0383458a074b87301
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for raxtik-etl 0.1.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for raxtik_etl-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page