elizaOS SQL Plugin - PostgreSQL and PGLite database adapters for elizaOS
Project description
elizaOS SQL Plugin (Python)
The Python implementation of the elizaOS SQL Plugin - PostgreSQL and PGLite database adapters for elizaOS agents.
Installation
pip install elizaos-plugin-sql
Features
- PostgreSQL adapter with vector search support via pgvector
- PGLite adapter for lightweight local development
- SQLAlchemy ORM with async support
- Automatic migrations using Alembic
- Runtime migration service compatible with TypeScript RuntimeMigrator
- Plugin schema namespacing for isolation
- Vector embeddings for semantic search
- Full type safety with Pydantic models
Quick Start
PostgreSQL
from elizaos import AgentRuntime, Character
from elizaos_plugin_sql import PostgresAdapter
# Create the database adapter
adapter = PostgresAdapter(
connection_string="postgresql+asyncpg://user:pass@localhost/db",
agent_id="12345678-1234-1234-1234-123456789012",
)
# Create the runtime with the adapter
character = Character(name="Agent", bio="A helpful agent")
runtime = AgentRuntime(
character=character,
adapter=adapter,
)
await runtime.initialize()
PGLite (Local Development)
from elizaos import AgentRuntime, Character
from elizaos_plugin_sql import PGLiteAdapter
# Create a local PGLite adapter
adapter = PGLiteAdapter(
data_dir="./data/pglite",
agent_id="12345678-1234-1234-1234-123456789012",
)
character = Character(name="Agent", bio="A helpful agent")
runtime = AgentRuntime(
character=character,
adapter=adapter,
)
await runtime.initialize()
Schema
The plugin provides the following database tables:
agents- Agent configurationsentities- Users and other entitiescomponents- Entity componentsrooms- Conversation roomsworlds- World containersmemories- Stored memories/messagesembeddings- Vector embeddingsrelationships- Entity relationshipstasks- Task queuecache- Key-value cachelogs- Activity logs
Migration System
The package includes a migration service compatible with the TypeScript RuntimeMigrator:
from elizaos_plugin_sql import MigrationService, derive_schema_name
# Create migration service
migration_service = MigrationService(engine)
await migration_service.initialize()
# Get migration status
status = await migration_service.get_status("@your-org/plugin-name")
# Derive schema name for plugin isolation
schema_name = derive_schema_name("@your-org/plugin-name")
# Returns: "your_org_plugin_name"
Running Alembic Migrations
# Set database URL
export POSTGRES_URL="postgresql+asyncpg://user:pass@localhost/db"
# Generate a new migration
alembic revision --autogenerate -m "Add new table"
# Apply migrations
alembic upgrade head
# Rollback
alembic downgrade -1
Development
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run migration tests
pytest tests/test_migrations.py
# Type checking
mypy elizaos_plugin_sql
# Linting
ruff check elizaos_plugin_sql
License
MIT
Project details
Release history Release notifications | RSS feed
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 elizaos_plugin_sql-2.0.0a4.tar.gz.
File metadata
- Download URL: elizaos_plugin_sql-2.0.0a4.tar.gz
- Upload date:
- Size: 19.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a97d3548417f405fb59729fa37fc5391868d0f8e521c3877c3962eed8f6c2df
|
|
| MD5 |
92ea7e2ca3b69affb8b464b68f42f323
|
|
| BLAKE2b-256 |
046a56092612d737600cbc83799867e598d3ab8f2eb3233f253243e2729c29d6
|
File details
Details for the file elizaos_plugin_sql-2.0.0a4-py3-none-any.whl.
File metadata
- Download URL: elizaos_plugin_sql-2.0.0a4-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07937b27bf9e54ee38214cf541364df1326cab6e1e1399bbd85b6149fcbc914d
|
|
| MD5 |
ed732f95ec4268ec9ac81903e0a2c4ec
|
|
| BLAKE2b-256 |
ed9b58a5234b35578e890019137140c0328282f33a5c85a45668f28d5b376005
|