Skip to content

SQLA-Wrapper

A friendly wrapper for modern SQLAlchemy and Alembic.

SQLA-Wrapper#

SQLA-Wrapper is a wrapper for SQLAlchemy and Alembic that simplifies many aspects of its setup.

It works with the newer 2.0 style query API introduced in SQLAlchemy 1.4, and can be used with most web frameworks.

Includes#

  • A SQLAlchemy wrapper, that does all the SQLAlchemy setup and gives you:

    • A scoped session extended with some useful active-record-like methods and pagination.
    • A declarative base class.
    • A helper for performant testing with a real database.
    from sqla_wrapper import SQLAlchemy
    
    db = SQLAlchemy("sqlite:///db.sqlite", **options)
    # You can also use separated host, name, etc.
    # db = SQLAlchemy(user=…, password=…, host=…, port=…, name=…)
    
  • An Alembic wrapper that loads the config from your application instead of from separated alembic.ini and env.py files.

    from sqla_wrapper import Alembic, SQLAlchemy
    
    db = SQLAlchemy()
    alembic = Alembic(db, "db/migrations")
    

Installation#

Install the package using pip. The SQLAlchemy and Alembic libraries will be installed as dependencies.

pip install sqla-wrapper

Resources#

Back to top