Skip to main content

Databases Overview

Memori is database-agnostic. With the BYODB (Bring Your Own Database) approach, your data stays on your infrastructure — you choose the database, you own the data.
Want a zero-setup option? Try Memori Cloud at app.memorilabs.ai.

Supported Databases

DatabaseBest ForDriverConnection String
SQLiteDevelopment, prototypingBuilt-in (sqlite3)sqlite:///memori.db
PostgreSQLProduction, high concurrencypsycopg2-binarypostgresql://user:pass@host/db
MySQLExisting MySQL infrastructurepymysql or mysqlclientmysql+pymysql://user:pass@host/db
MariaDBMySQL-compatible alternativepymysql or mysqlclientmysql+pymysql://user:pass@host/db
OracleEnterprise environmentsoracledb or cx_Oracleoracle+oracledb://user:pass@host/service
MongoDBDocument-oriented, flexible schemapymongomongodb://host:27017
CockroachDBDistributed SQL, global scalepsycopg2-binarycockroachdb+psycopg2://user:pass@host/db
OceanBaseDistributed HTAP workloadspyobvectormysql+pyobvector://user:pass@host:2881/db
NeonServerless PostgreSQLpsycopg2-binarypostgresql://user:[email protected]/db
SupabaseHosted PostgreSQL with extraspsycopg2-binarypostgresql://user:[email protected]:5432/db
MariaDB uses the same drivers and connection strings as MySQL. Neon and Supabase are PostgreSQL-compatible.

Managed Providers

Memori also works with hosted services that expose standard PostgreSQL/MySQL endpoints:
ProviderEngine CompatibilityTypical Host Pattern
NeonPostgreSQL*.neon.tech
SupabasePostgreSQL*.supabase.co
AWS RDSPostgreSQL/MySQL*.rds.amazonaws.com
AWS AuroraPostgreSQL/MySQL*.rds.amazonaws.com

Quick Start Code

import sqlite3
from memori import Memori

def get_connection():
    return sqlite3.connect("memori.db")

mem = Memori(conn=get_connection)
mem.config.storage.build()

Connection Methods

Memori supports four connection methods depending on your stack:
MethodDescriptionUse Case
SQLAlchemyIndustry-standard ORM with sessionmakerProduction applications, connection pools
DB API 2.0Direct Python database drivers (PEP 249)Lightweight, minimal dependencies
Django ORMNative Django ORM integrationDjango applications
MongoDBFunction returning a database objectDocument databases via pymongo
Memori accepts a conn parameter — a callable that returns a new connection each time it is called.

SQLAlchemy Databases

For SQLite, PostgreSQL, MySQL, MariaDB, Oracle, CockroachDB, OceanBase, and managed providers like Neon/Supabase/RDS/Aurora: pass a sessionmaker.
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from memori import Memori

engine = create_engine("postgresql://user:password@localhost/mydb")
SessionLocal = sessionmaker(bind=engine)

mem = Memori(conn=SessionLocal)

DB API 2.0

For direct database connections using PEP 249-compliant drivers: pass a function that returns a connection object.
import psycopg2
from memori import Memori

def get_connection():
    return psycopg2.connect(
        dbname="mydb",
        user="user",
        password="password",
        host="localhost"
    )

mem = Memori(conn=get_connection)

Django ORM

For Django applications, pass your Django database connection directly.
from django.db import connection
from memori import Memori

mem = Memori(conn=connection)
mem.config.storage.build()

MongoDB

For MongoDB: pass a function returning a database instance.
from pymongo import MongoClient
from memori import Memori

client = MongoClient("mongodb://localhost:27017")

def get_db():
    return client["memori_db"]

mem = Memori(conn=get_db)

Database Tables

When you run mem.config.storage.build(), Memori creates these tables:
  • memori_conversation_message - Raw conversation messages
  • memori_entity_fact - Extracted facts about entities
  • memori_process_attribute - Process-specific attributes
  • memori_knowledge_graph - Relationship graph data
  • memori_session - Session tracking
Since you own the database, you can query these tables directly for custom analytics, backups, or integration with other systems.

Inspect Your Memories

Query your database directly to see what Memori stored:
sqlite3 memori.db "SELECT * FROM memori_entity_fact;"

Next Steps

1

Quick Start with SQLite

Build your first memory-enabled application in under 3 minutes.Go to Quick Start →
2

Database-Specific Guides

Explore detailed setup guides for each database in the sidebar.View database guides in the sidebar
3

Choose Your LLM

Integrate with your preferred LLM provider.View LLM integrations in the sidebar

Build docs developers (and LLMs) love