attrs-sqlalchemy 0.1.0

Last updated:

0 purchases

attrs-sqlalchemy 0.1.0 Image
attrs-sqlalchemy 0.1.0 Images
Add to Cart

Description:

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')"

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.