Skip to main content

sqlalchemy-memory

PyPI - Version CI Documentation PyPI - Downloads

In‑memory SQLAlchemy 2.0 dialect for blazing‑fast prototyping

A pure‑Python SQLAlchemy 2.0 dialect that runs entirely in RAM. It avoids typical database I/O and ORM overhead while maintaining full compatibility with the SQLAlchemy 2.0 Core and ORM APIs. Ideal for rapid prototyping, backtesting engines, simulations.

Why ?

This project was inspired by the idea of building a fast, introspectable, no-dependency backend for SQLAlchemy.

It is useful for:

  • Prototyping new applications

  • Educational purposes

  • Testing ORM logic without spinning up a real database engine

Unlike traditional in-memory solutions like SQLite, sqlalchemy-memory fully avoids serialization, connection pooling, and driver overhead, leading to much faster in-memory performance while keeping the familiar SQLAlchemy API.

It is also perfect for applications that need a lightweight, high-performance store compatible with SQLAlchemy, such as backtesting engines, simulators, or other tools where you don't want to maintain a separate in-memory layer alongside your database models.

Data is kept purely in RAM and is volatile: it is not persisted across application restarts and is cleared when the engine is disposed.

Features

  • SQLAlchemy 2.0 support: ORM & Core expressions, sync & async modes
  • Zero I/O overhead: pure in‑RAM storage (dict/list under the hood)
  • Commit/rollback support
  • Index support: indexes are recognized and used for faster lookups
  • Lazy query evaluation: supports generator pipelines and short-circuiting
    • first()-style queries avoid scanning the full dataset
    • Optimized for read-heavy workloads and streaming filters

Benchmark

Curious how sqlalchemy-memory stacks up?

View Benchmark Results comparing sqlalchemy-memory to in-memory SQLite

Installation

pip install sqlalchemy-memory

Documentation

See the official documentation for usage examples

Testing

Simply run make tests

License

This project is licensed under the MIT License. See LICENSE for details.

Metadata

Release files for sqlalchemy-memory 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqlalchemy-memory 0.4.0
File Size Uploaded
sqlalchemy_memory-0.4.0.tar.gz 23.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sqlalchemy-memory 0.4.0
File Interpreter ABI Platform
sqlalchemy_memory-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 44.4 kB

Release files / sqlalchemy_memory-0.4.0.tar.gz

Download URL sqlalchemy_memory-0.4.0.tar.gz
Size 23.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d0e1e4199d84a440d516aa2a23ad5271658b7de19c3a6e3dd19f25df3bef9c0a
BLAKE2b-256 checksum
How to use checksums
ec326421a518c5e9bde10f1002df82b624f32112f51b474b04b3075fb02111bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / sqlalchemy_memory-0.4.0-py3-none-any.whl

Download URL sqlalchemy_memory-0.4.0-py3-none-any.whl
Size 21.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8960324ab3a52e40b258ffb74e577a9e7d029c48846e90e806ddf419f91536bc
BLAKE2b-256 checksum
How to use checksums
2ab9f4ad379eb3b083f2dfce8d5eab155c6cd50b2043463b5d7d44a69dc81334
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page