{"id":15908901,"url":"https://github.com/dnouri/kemi","last_synced_at":"2025-06-25T13:06:19.917Z","repository":{"id":2832427,"uuid":"3835176","full_name":"dnouri/kemi","owner":"dnouri","description":"kemi is an add-on for SQLAlchemy that aims to make defining relations with declarative easier for the most common cases.","archived":false,"fork":false,"pushed_at":"2012-03-26T17:21:11.000Z","size":89,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T00:42:41.432Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://pypi.python.org/pypi/kemi","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dnouri.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-03-26T17:09:45.000Z","updated_at":"2016-09-02T01:01:41.000Z","dependencies_parsed_at":"2022-09-25T00:12:47.191Z","dependency_job_id":null,"html_url":"https://github.com/dnouri/kemi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dnouri/kemi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnouri%2Fkemi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnouri%2Fkemi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnouri%2Fkemi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnouri%2Fkemi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dnouri","download_url":"https://codeload.github.com/dnouri/kemi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnouri%2Fkemi/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261879315,"owners_count":23223739,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-06T14:41:00.355Z","updated_at":"2025-06-25T13:06:19.890Z","avatar_url":"https://github.com/dnouri.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"kemi\n====\n\nkemi is an add-on for SQLAlchemy_ that aims to make defining relations\nwith declarative easier for the most common cases.\n\nConsider this example from the SQLAlchemy docs::\n\n  class Customer(Base):\n      __tablename__ = 'customer'\n      id = Column(Integer, primary_key=True)\n      name = Column(String)\n\n      billing_address_id = Column(Integer, ForeignKey(\"address.id\"))\n      shipping_address_id = Column(Integer, ForeignKey(\"address.id\"))\n\n      billing_address = relationship(\"Address\",\n                      primaryjoin=\"Address.id==Customer.billing_address_id\")\n      shipping_address = relationship(\"Address\",\n                      primaryjoin=\"Address.id==Customer.shipping_address_id\")\n\nUsing kemi, this can be written as::\n\n  class Customer(Base):\n      name = Column(String)\n      billing_address = relationship(\"Address\")\n      shipping_address = relationship(\"Address\")\n\nThings that kemi currently does:\n\n* adds a ``__tablename__`` if none is explicitely set on the class\n* adds an ``id`` column if no primary key column is present\n* adds foreign key columns for relationships if no foreign key columns\n  are present\n* adds ``primaryjoins`` to relationships if they're not set\n\nTo use kemi, you need to use its DeclarativeMeta class when you make a\ncall to ``declarative_base``::\n\n  from sqlalchemy.ext.declarative import declarative_base\n  from kemi import DeclarativeMeta\n\n  Base = declarative_base(metaclass=DeclarativeMeta)  \n\n  class Customer(Base):\n      name = Column(String)\n      billing_address = relationship(\"Address\")\n      shipping_address = relationship(\"Address\")\n\n\n.. _SQLAlchemy: http://www.sqlalchemy.org/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnouri%2Fkemi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdnouri%2Fkemi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnouri%2Fkemi/lists"}