{"id":10254,"library":"sqlalchemy-repr","title":"SQLAlchemy Repr","description":"sqlalchemy-repr, currently at version 0.1.0, is a lightweight Python library that automatically generates human-readable `__repr__` methods for SQLAlchemy declarative models. It aims to simplify debugging and logging by providing informative string representations of model instances without manual boilerplate. The project is stable but has a low release cadence.","status":"active","version":"0.1.0","language":"python","source_language":"en","source_url":"https://github.com/manicmaniac/sqlalchemy-repr","tags":["sqlalchemy","repr","debugging","orm"],"install":[{"cmd":"pip install sqlalchemy-repr","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for ORM model integration.","package":"SQLAlchemy","optional":false}],"imports":[{"wrong":"from sqlalchemy_repr import ReprMixin","symbol":"Repr","correct":"from sqlalchemy_repr import Repr"},{"symbol":"PrettyRepr","correct":"from sqlalchemy_repr import PrettyRepr"},{"symbol":"RepresentableBase","correct":"from sqlalchemy_repr import RepresentableBase"}],"quickstart":{"code":"from sqlalchemy import create_engine, Column, Integer, String\nfrom sqlalchemy.orm import sessionmaker\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy_repr import ReprMixin\n\n# 1. Setup SQLAlchemy Base\nBase = declarative_base()\n\n# 2. Define a model with ReprMixin\nclass User(ReprMixin, Base):\n    __tablename__ = 'users'\n    id = Column(Integer, primary_key=True)\n    name = Column(String)\n    email = Column(String)\n\n    # Optional: Customize which attributes are shown in repr\n    _repr_values = ['id', 'name']\n\n# 3. Create an engine and tables\nengine = create_engine('sqlite:///:memory:')\nBase.metadata.create_all(engine)\n\n# 4. Create a session\nSession = sessionmaker(bind=engine)\nsession = Session()\n\n# 5. Create and add an instance\nuser1 = User(id=1, name='Alice', email='alice@example.com')\nuser2 = User(id=2, name='Bob', email='bob@example.com')\nsession.add_all([user1, user2])\nsession.commit()\n\n# 6. Demonstrate the custom repr\nretrieved_user = session.query(User).filter_by(name='Alice').first()\nprint(f\"User instance repr: {retrieved_user}\")\n# Expected output (approx): User(id=1, name='Alice')\n\n# Clean up\nsession.close()","lang":"python","description":"This quickstart demonstrates how to integrate `ReprMixin` with a SQLAlchemy declarative model. By inheriting `ReprMixin` alongside `Base`, your model instances will automatically gain a sensible string representation. The example also shows how to customize the included attributes using `_repr_values`."},"warnings":[{"fix":"Monitor the project's GitHub repository for updates if using very new SQLAlchemy versions. Be prepared to implement custom `__repr__` methods or fork the library for compatibility if encountering issues with future SQLAlchemy releases.","message":"The project `sqlalchemy-repr` is stable but has a low level of active development. While it works reliably with existing SQLAlchemy versions, new SQLAlchemy features or major API changes might not be immediately supported.","severity":"gotcha","affected_versions":"0.1.0"},{"fix":"Explicitly define the `_repr_values` attribute on your model to control which columns are included in the representation. For example: `_repr_values = ['id', 'username']` to exclude sensitive fields like `password_hash`.","message":"By default, `ReprMixin` includes all mapped columns in the `__repr__` output. For models containing sensitive data (e.g., passwords, API keys, private information), this could lead to unintended exposure in logs or during debugging.","severity":"gotcha","affected_versions":"all"},{"fix":"When defining models with such relationships, consider carefully setting `_repr_values` to exclude relationship attributes. For very complex cases, implement a custom `__repr__` method to ensure controlled and efficient output.","message":"For models with complex, deeply nested, or circular relationships, relying solely on `ReprMixin`'s default behavior can lead to overly verbose representations or even infinite recursion if relationships are eagerly loaded.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'0.1.0':9 'aim':28 'automat':16 'boilerpl':44 'cadenc':54 'current':6 'debug':31,57 'declar':25 'generat':17 'human':19 'human-read':18 'inform':36 'instanc':41 'librari':14 'lightweight':12 'log':33 'low':52 'manual':43 'method':22 'model':26,40 'orm':58 'project':46 'provid':35 'python':13 'readabl':20 'releas':53 'repr':2,5,21,56 'represent':38 'simplifi':30 'sqlalchemi':1,4,24,55 'sqlalchemy-repr':3 'stabl':48 'string':37 'version':8 'without':42","created_at":"2026-04-17T01:23:10.307660+00:00","updated_at":"2026-04-17T01:23:10.307660+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.1.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/manicmaniac/sqlalchemy-repr","docs":null,"changelog":null,"pypi":"https://pypi.org/project/sqlalchemy-repr/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-30","last_verified":"2026-06-30","next_check":"2026-07-30","install_tag":null}}