Launched January 6, 2026
context-async-sqlalchemy

context-async-sqlalchemy

The best way to use sqlalchemy in an async python application

FreeBoilerplateHelpersOpen Source268 impressions#268 of its week

Provides a super convenient way to work with SQLAlchemy in asynchronous applications. It handles the lifecycle management of the engine, sessions, and transactions. The main goal is to provide quick and easy access to a session, without worrying about opening or closing it when it’s not necessary. Key features: - Extremely easy to use - Automatically manages the lifecycle of the engine, sessions, and transactions (autocommit / autorollback) - Does not interfere with manually opening or closing sessions and transactions when needed - Framework-agnostic - works with any web framework - Not a wrapper around SQLAlchemy - Convenient for testing - Runtime host switching - Supports multiple databases and multiple sessions per database - Provides tools for running concurrent SQL queries - Fully lazy initialization

A library that simplifies async SQLAlchemy usage by managing engine, sessions, and transactions via contextvars.

for
Python developers building asynchronous applications with SQLAlchemy
pricing
open source
license
MIT
krylosov-aa/context-async-sqlalchemy 63 1Pythonupdated 4 months ago
works withSQLAlchemyasynciocontextvars

Key features

6 features of context-async-sqlalchemy
  • Automatic lifecycle management — Handles engine, session, and transaction creation, commit, rollback, and cleanup automatically.
  • Framework-agnostic — Works with any async web framework without requiring specific integrations.
  • Lazy initialization — Initializes the database engine only when a session is first requested.
  • Concurrent query support — Provides tools to run multiple SQL queries concurrently within the same context.
  • Runtime host switching — Allows changing database hosts at runtime without restarting the application.
  • Testing convenience — Simplifies test setup by managing sessions automatically.

Use cases

  • Reuse the same DB session across async coroutines without manual passing
  • Write tests that need automatic transaction rollback
  • Switch between multiple databases in a single app
  • Run parallel queries in background tasks without extra boilerplate

context-async-sqlalchemy vs alternatives

context-async-sqlalchemyPrismaDrizzle ORMSupabaseFirebase
Best forAsync SQLAlchemy session managementTypeScript ORM with built-in clientLightweight TypeScript ORMHosted Postgres backendNoSQL backend platform
PricingOpen sourceFreeFreeSubscriptionSubscription
DevHunt upvotes00000
LaunchedJan 2026————

context-async-sqlalchemy FAQ

Do I need to replace my existing SQLAlchemy code?+

No, the library is not a wrapper; you can still manually open/close sessions when needed.

Is it compatible with FastAPI or Starlette?+

Yes, it is framework-agnostic and works with any async framework such as FastAPI or Starlette.

How does it handle transactions?+

It automatically commits or rolls back transactions at the end of the request, but you can also manage them manually.

Can I use multiple databases simultaneously?+

Yes, it supports multiple databases and multiple sessions per database.

Is the library open source?+

Yes, it is released under the MIT license and available on GitHub.

Summarized by DevHunt from github.com · Oct 6, 2026. Details may change; check the official site.