Retort
Retort is a schema migration tool for SQLAlchemy, compares DB schema against table metadata, and updates DB schema according to this.
It depends on the Alembic autogenerate.
Requirements
Retort works with
Python 3.3+
SQLAlchemy
Alembic
autopep8
Installation
via pip
$ pip install retort
via setup.py
$ python setup.py install
Basic Usage Examples
Generate config file (retort_config.py)
(venv) tpdn@example:~/retort_example$ retort init
Create retort_conf.py.
Edit config file
# retort_config.py
from model import user
TARGETS = [
{
'engine': user.engine, #sqlalchemy engine
'metadata': user.Base.metadata #sqlalchemy metadata
},
]
# model/user.py
from sqlalchemy import Column, Integer, String, create_engine
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('mysql+pymysql://foobar:abcdef@localhost/retort_test_db')
Base = declarative_base()
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
name = Column(String(255))
fullname = Column(String(255))
xyz = Column(String(255))
Apply
(venv) tpdn@example:~/retort_example$ retort apply
====================
url: mysql+pymysql://foobar:abcdef@localhost/retort_test_db
logging_name: None
====================
op.create_table('users',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=255), nullable=True),
sa.Column('fullname', sa.String(length=255), nullable=True),
sa.Column('xyz', sa.String(length=255), nullable=True),
sa.PrimaryKeyConstraint('id')
)
Do you really want to apply this? [y/n]: y
Applying migration......
====================
url: mysql+pymysql://foobar:abcdef@localhost/retort_test_db
logging_name: None
====================
op.create_table('users',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=255), nullable=True),
sa.Column('fullname', sa.String(length=255), nullable=True),
sa.Column('xyz', sa.String(length=255), nullable=True),
sa.PrimaryKeyConstraint('id')
)
---> Processing time: 0.0894(sec)
Complete!
Update model(remove xyz column)
# model/user.py
from sqlalchemy import Column, Integer, String, create_engine
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('mysql+pymysql://foobar:abcdef@localhost/retort_test_db')
Base = declarative_base()
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
name = Column(String(255))
fullname = Column(String(255))
# xyz = Column(String(255))
Apply with –sql option
(venv) tpdn@example:~/retort_example$ retort apply --sql
====================
url: mysql+pymysql://foobar:abcdef@localhost/retort_test_db
logging_name: None
====================
ALTER TABLE users DROP COLUMN xyz;
Do you really want to apply this? [y/n]: y
Applying migration......
====================
url: mysql+pymysql://foobar:abcdef@localhost/retort_test_db
logging_name: None
====================
ALTER TABLE users DROP COLUMN xyz;
---> Processing time: 0.0745(sec)
Complete!
Commands and Options
retort init retort apply --sql # print sql mode --dry-run # dry run (no database update) --yes # skip confirmation --without-drop # without drop operations (DROP TABLE, DROP COLUMN, DROP INDEX, DROP CONSTRAINT) retort print_operations --sql --without-drop
Licence
BSD License (2-Clause)
Metadata
Release files for retort 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| retort-0.1.0.tar.gz | 8.1 kB | Without provenance | Details for retort-0.1.0.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| retort-0.1.0-py3.5.egg | Legacy Egg format | - | - | Details for retort-0.1.0-py3.5.egg |
| retort-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for retort-0.1.0-py3-none-any.whl |
Total release size: 29.0 kB
Release files / retort-0.1.0.tar.gz
| Download URL | retort-0.1.0.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eba5262f8563b63e114d70ebb60ea4c452ac0c463d85614497080fc975353976
|
|
BLAKE2b-256 checksum How to use checksums |
8e05b753bef4f254d2511468818397f749e2b4520c76c189633f7933f231c630
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / retort-0.1.0-py3.5.egg
| Download URL | retort-0.1.0-py3.5.egg |
|---|---|
| Size | 12.3 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
19e4fb928d573c69067354c96f3a139b0c5f52da98907dd5bc5012d7c3aa0158
|
|
BLAKE2b-256 checksum How to use checksums |
225b3629f3126e221838f46be56e2f2b35c794252ec41ff617d619ff541620b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / retort-0.1.0-py3-none-any.whl
| Download URL | retort-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d280ec33c8f7421ea0cb1870b92e3f369b16639fa0188ca0bca297cb883616b6
|
|
BLAKE2b-256 checksum How to use checksums |
22f332f8b819a6bc50a51ac999545165e45d794d876273137528b43e259a71ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for retort 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.