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.2.tar.gz (44.4 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.2-py3-none-any.whl (33.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mythologizer_postgres-0.1.2.tar.gz
  • Upload date:
  • Size: 44.4 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.2.tar.gz
Algorithm Hash digest
SHA256 14fb8bcc23397f7a715a70d84c546167def27efb904f5c685a84e18858707cf9
MD5 595b753da562ace02fe5bfd3b0570bdc
BLAKE2b-256 a193bae6dea986647bb375e6addfc646b742abe57f3ecb5056cbb3489a8d65c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mythologizer_postgres-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e00086aac6b5ed16fa8ab43c098295cb7646204a1bba45de055f9f39e4c6c956
MD5 56ef79b10ec387220c46eb9f54812b69
BLAKE2b-256 71c3e8ea9b047230458fc99e9f8732a42bec81a9b06b9067c10537cbaa2e6808

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