Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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 configurations
  • entities - Users and other entities
  • components - Entity components
  • rooms - Conversation rooms
  • worlds - World containers
  • memories - Stored memories/messages
  • embeddings - Vector embeddings
  • relationships - Entity relationships
  • tasks - Task queue
  • cache - Key-value cache
  • logs - 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

elizaos_plugin_sql-2.0.0a5.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

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

elizaos_plugin_sql-2.0.0a5-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file elizaos_plugin_sql-2.0.0a5.tar.gz.

File metadata

  • Download URL: elizaos_plugin_sql-2.0.0a5.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for elizaos_plugin_sql-2.0.0a5.tar.gz
Algorithm Hash digest
SHA256 84c6f14d05c9be30f844b3ad7947452435f2306c5287023816f1e216fe6408b2
MD5 c1f0d1fd605f00ac834f2e38af78c7e5
BLAKE2b-256 a4bf6aaa56a0ae754a3a8cf6d9225defe8472baa71c1a0f5646c0ba4e88fb9f5

See more details on using hashes here.

File details

Details for the file elizaos_plugin_sql-2.0.0a5-py3-none-any.whl.

File metadata

File hashes

Hashes for elizaos_plugin_sql-2.0.0a5-py3-none-any.whl
Algorithm Hash digest
SHA256 40001092521dd6c86420d3d9fbac077e9c844e48a20cf4a84bc11e7c9ec8fccc
MD5 a35f80a006708b75fd46c70534ca5aa6
BLAKE2b-256 9bdd1807fa46f421aad7405da2c24bc5333cb667a31187f997da4e9613f0746a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.0.0a5 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page