Skip to main content

PostgreSQL database connector for mythology data with vector embeddings

Project description

Mythologizer PostgreSQL

A PostgreSQL database connector for mythology data with vector embeddings, built with SQLAlchemy and pgvector.

Installation

Using uv (recommended)

# Install in development mode
uv pip install -e .

# Or install from PyPI (when published)
uv add mythologizer_postgres

Using pip

pip install mythologizer_postgres

Package Structure

The package is organized into the following structure:

mythologizer_postgres/
├── __init__.py          # Core database functions
├── db.py               # Database connection and utilities
├── schema.py           # Database schema definitions
├── cli.py              # Command-line interface
└── connectors/         # Data access layer
    ├── __init__.py     # All connector functions
    ├── myth_store.py   # Myth data operations
    ├── mytheme_store.py # Mytheme data operations
    └── mythicalgebra/  # Myth algebra subpackage
        ├── __init__.py # Myth algebra functions
        └── mythic_algebra_connector.py # Myth algebra operations

Usage

Core Database Functions

Direct imports from the main package:

from mythologizer_postgres import (
    get_engine,
    get_session,
    session_scope,
    psycopg_connection,
    apply_schemas,
    check_if_tables_exist,
    ping_db,
    clear_all_rows,
    get_table_row_counts,
    MissingEnvironmentVariable,
    need,
    build_url,
)

# Example: Get a database session
with session_scope() as session:
    # Your database operations here
    pass

# Example: Check database connectivity
if ping_db():
    print("Database is accessible")

Connector Functions

Import all connector functions:

from mythologizer_postgres.connectors import (
    # Mytheme functions
    get_mythemes_bulk,
    get_mytheme,
    insert_mythemes_bulk,
    
    # Myth functions
    insert_myth,
    insert_myths_bulk,
    get_myth,
    get_myths_bulk,
    update_myth,
    update_myths_bulk,
    delete_myth,
    delete_myths_bulk,
    
    # Myth algebra functions
    get_myth_embeddings,
    get_myth_matrices,
    recalc_and_update_myths,
)

# Example: Get a myth by ID
myth = get_myth(123)

### Myth Algebra Functions

Import myth algebra functions specifically:

```python
from mythologizer_postgres.connectors.mythicalgebra import (
    get_myth_embeddings,
    get_myth_matrices,
    recalc_and_update_myths,
)

# Example: Get myth embeddings
embeddings = get_myth_embeddings([123, 124, 125])

# Example: Get myth matrices
matrices = get_myth_matrices([123, 124, 125])

# Example: Recalculate and update myths
updated_ids = recalc_and_update_myths([123, 124, 125])

Subpackage Access

You can also access the subpackages directly:

import mythologizer_postgres.connectors as connectors
import mythologizer_postgres.connectors.mythicalgebra as mythicalgebra

# Use the functions
myth = connectors.get_myth(123)
embedding = mythicalgebra.get_myth_embeddings(123)

Environment Variables

The package requires the following environment variables:

POSTGRES_USER=your_username
POSTGRES_PASSWORD=your_password
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=your_database

Development

Setup Development Environment

# Clone the repository
git clone <repository-url>
cd mythologizerDB

# Install in development mode
uv pip install -e .

# Run tests
uv run python test_imports.py

Building the Package

# Build source distribution and wheel
uv build

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

mythologizer_postgres-0.1.3.tar.gz (47.3 kB view details)

Uploaded Source

Built Distribution

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

mythologizer_postgres-0.1.3-py3-none-any.whl (37.8 kB view details)

Uploaded Python 3

File details

Details for the file mythologizer_postgres-0.1.3.tar.gz.

File metadata

  • Download URL: mythologizer_postgres-0.1.3.tar.gz
  • Upload date:
  • Size: 47.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for mythologizer_postgres-0.1.3.tar.gz
Algorithm Hash digest
SHA256 4604559987765ecb99b5371d91a38e7356d397c44ffd5cbce8ebeb33984925ae
MD5 132c21d7b4548a020385519954eb1264
BLAKE2b-256 7d348eac93ebbe231ee04a081e34b41d8c599114c45b4dd83268d563e398c2e5

See more details on using hashes here.

File details

Details for the file mythologizer_postgres-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for mythologizer_postgres-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5314643f6019aa0a9656ddeaf162c189d7fd754aef9b49424ef5e050de0d79df
MD5 8e5c8226823c7a8d20c83af397540333
BLAKE2b-256 c58b7edea90c9183ec66210f2d3eab148de3ebfb6abd4db6cffade34be3b40ca

See more details on using hashes here.

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