Skip to main content

Automatic migrations for SQLAlchemy

Project description

SQLSugar - Automatic migrations for SQLAlchemy

PyPI Changelog License

This library is for you if you want to use a real database without spending time to generate migrations. This is experimental and you should switch to Alembic as your project matures. This only supports adding new tables, columns and indexes.

Installation

Install this library using pip:

pip install sqlsugar

Usage

Look for examples with SQLAlchemy or SQLModel.

from sqlsugar import migrate

migrate(engine.connect(), Base.metadata)

How it works

We use Alembic to autogenerate the difference between the models you have defined with SQLAlchemy and the database. We then execute operations that create tables, add new columns or add new indexes. That is often all that's needed for rapid prototyping or running very small hobby projects.

However, we don't support renaming columns, dropping columns or removing tables. You should switch to using Alembic as your needs evolve. Alternatively, you can try running those migrations manually.

Development

To contribute to this library, first checkout the code. Then create a new virtual environment:

cd sqlsugar
python -m venv .venv
source .venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'
pre-commit install

To run the tests:

pytest

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

sqlsugar-0.1.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

sqlsugar-0.1-py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page