Last updated:
0 purchases
attrssqlalchemy 0.1.0
Use attrs to add __repr__, __eq__,
__cmp__, and __hash__ methods according to the fields on a SQLAlchemy
model class.
from attrs_sqlalchemy import attrs_sqlalchemy
@attrs_sqlalchemy
class MyModel(Base):
__tablename__ = 'mymodel'
id = sa.Column(Integer, primary_key=True)
text = sa.Column(sa.String)
instance = MyModel(id=1, text='hello')
same_data = MyModel(id=1, text='hello')
same_pk = MyModel(id=1, text='world')
assert instance == same_data
assert instance != same_pk
assert repr(instance) == "MyModel(id=1, text='hello')"
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.