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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mythologizer_postgres-0.1.4.tar.gz.
File metadata
- Download URL: mythologizer_postgres-0.1.4.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da6d48438e6fe0e3763e2251dd00e566cfe5a2b8baea1cc655d692525134373b
|
|
| MD5 |
42f48a4543e96109dd042f30a6de32a3
|
|
| BLAKE2b-256 |
de662b693844456916bca8257533b9c9e2d5c19484692c3545851b1079a1ebcb
|
File details
Details for the file mythologizer_postgres-0.1.4-py3-none-any.whl.
File metadata
- Download URL: mythologizer_postgres-0.1.4-py3-none-any.whl
- Upload date:
- Size: 33.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b31b1e52e2591295bf3ff7b3dc938cece6421155eaa70da048a374de5008992
|
|
| MD5 |
c2dfaf4a9d4a8643da42b3de7e9cbddc
|
|
| BLAKE2b-256 |
41766d332d0414a7e561a76ea1876623e40e452cf128ce38136352c67f58c4d8
|