https://github.com/teemu/sqlsugar
Automatic migrations for SQLAlchemy 🍭
https://github.com/teemu/sqlsugar
alembic autogenerated database migrations sqlalchemy
Last synced: about 2 months ago
JSON representation
Automatic migrations for SQLAlchemy 🍭
- Host: GitHub
- URL: https://github.com/teemu/sqlsugar
- Owner: Teemu
- License: mit
- Created: 2022-11-20T14:23:56.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-20T21:24:01.000Z (over 3 years ago)
- Last Synced: 2025-06-27T03:23:35.066Z (about 1 year ago)
- Topics: alembic, autogenerated, database, migrations, sqlalchemy
- Language: Python
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SQLSugar - Automatic migrations for SQLAlchemy

[](https://pypi.org/project/sqlsugar/)
[](https://github.com/Teemu/sqlsugar/releases)
[](https://github.com/Teemu/sqlsugar/blob/main/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](https://alembic.sqlalchemy.org/en/latest/) as your project matures. This only supports adding new tables, columns and indexes.
## Installation
Install this library using `pip`:
pip install sqlsugar
## Usage
See our examples for [SQLAlchemy](https://github.com/Teemu/sqlsugar/blob/main/examples/use_with_sqlalchemy.py) and [SQLModel](https://github.com/Teemu/sqlsugar/blob/main/examples/use_with_sqlmodel.py).
```python
from sqlsugar import migrate
# You only need this command to handle creating tables & running migrations
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