{"id":13501944,"url":"https://github.com/agateblue/lifter","last_synced_at":"2025-03-29T10:32:32.614Z","repository":{"id":48614903,"uuid":"51960890","full_name":"agateblue/lifter","owner":"agateblue","description":"A generic query engine, inspired by Django ORM","archived":true,"fork":false,"pushed_at":"2022-01-21T17:27:12.000Z","size":409,"stargazers_count":449,"open_issues_count":8,"forks_count":16,"subscribers_count":16,"default_branch":"develop","last_synced_at":"2025-03-20T16:17:08.061Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/agateblue.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-17T22:42:41.000Z","updated_at":"2024-05-23T17:49:15.000Z","dependencies_parsed_at":"2022-09-12T15:12:30.969Z","dependency_job_id":null,"html_url":"https://github.com/agateblue/lifter","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agateblue%2Flifter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agateblue%2Flifter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agateblue%2Flifter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agateblue%2Flifter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agateblue","download_url":"https://codeload.github.com/agateblue/lifter/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246174136,"owners_count":20735406,"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-07-31T22:01:56.082Z","updated_at":"2025-03-29T10:32:32.250Z","avatar_url":"https://github.com/agateblue.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"===============================\nWhat is lifter?\n===============================\n\n.. image:: https://img.shields.io/pypi/v/lifter.svg\n        :target: https://pypi.python.org/pypi/lifter\n\n.. image:: https://readthedocs.org/projects/lifter/badge/?version=latest\n        :target: http://lifter.readthedocs.org/en/latest/?badge=latest\n\n.. image:: https://travis-ci.org/EliotBerriot/lifter.svg?branch=master\n    :target: https://travis-ci.org/EliotBerriot/lifter\n\n.. image:: https://travis-ci.org/EliotBerriot/lifter.svg?branch=develop\n    :target: https://travis-ci.org/EliotBerriot/lifter\n\n\nLifter is a generic query engine, inspired by Django ORM and SQLAlchemy.\n\nIts goal is to provide a unique interface to query any type of data, regardless of the underlying query language or data backend (SQL, REST, Python objects...).\n\n**Warning**: This package is still in alpha state and a lot of work is still needed to make queries faster and efficient.\nContributions are welcome :)\n\nUseful links:\n\n- Documentation is available at http://lifter.readthedocs.org\n- Ask your programming questions on Stack Overflow using the tag `python-lifter \u003chttp://stackoverflow.com/questions/tagged/python-lifter\u003e`_\n\nFeatures\n--------\n\n* Queryset API similar to Django_  and SQLAlchemy_\n* Lazy querysets\n* Composable queries\n* Lightweight: very little dependencies\n* Tested and working on Python 2.7 to Python 3.5\n\n.. _Django: https://docs.djangoproject.com/en/1.9/ref/models/querysets/\n.. _SQLAlchemy: http://docs.sqlalchemy.org/en/rel_1_0/orm/tutorial.html#common-filter-operators\n\nExample usage\n-------------\n\nConsider the following list of users, returned from a REST API endpoint:\n\n.. code-block:: python\n\n    users = [\n        {\n            \"is_active\": True,\n            \"age\": 35,\n            \"eye_color\": \"brown\",\n            \"name\": \"Bernard\",\n            \"gender\": \"male\",\n            \"email\": \"bernard@blackbooks.com\",\n        },\n        {\n            \"is_active\": True,\n            \"age\": 34,\n            \"eye_color\": \"brown\",\n            \"name\": \"Manny\",\n            \"gender\": \"male\",\n            \"email\": \"manny@blackbooks.com\",\n        },\n        {\n            \"is_active\": True,\n            \"age\": 35,\n            \"eye_color\": \"brown\",\n            \"name\": \"Fran\",\n            \"gender\": \"female\",\n            \"email\": \"fran@blackbooks.com\",\n        },\n        # And so on ...\n    ]\n\nNow, imagine you have to extract data from this list. Let's compare how you can do this using regular Python\nand lifter.\n\nTo use lifter in your project, you'll only need the following instructions:\n\n.. code-block:: python\n\n    import lifter.models\n    from lifter.backends.python import IterableStore\n\n    class User(lifter.models.Model):\n        pass\n\n    store = IterableStore(users)\n    manager = store.query(User)\n\nGetting all active 26 years old users:\n\n.. code-block:: python\n\n    # vanilla Python\n    results = [\n        user for user in users\n        if user['age'] == 26 and user['is_active']\n    ]\n\n    # lifter\n    results = manager.filter(User.age == 26, User.is_active == True)\n\nGetting names and emails of inactive users under 56:\n\n.. code-block:: python\n\n    # vanilla Python\n    results = [\n        (user['name'], user['email']) for user in users\n        if not user['is_active'] and user['age'] \u003c 56\n    ]\n\n    # lifter\n    results = manager.filter(User.is_active == False, User.age \u003c 56)\\\n                     .values_list('name', 'email')\n\nGetting all active users except the one with brown eyes and sort them by age:\n\n.. code-block:: python\n\n    # vanilla Python\n    raw_results = [\n        user for user in users\n        if user['is_active'] and not user['eye_color'] == 'brown'\n    ]\n    results = sorted(raw_results, key=lambda v: v['age'])\n\n    # lifter\n    results = manager.filter(User.is_active == True)\\\n                     .exclude(User.eye_color == 'brown')\\\n                     .order_by('age')\n\nGetting minimum and average women age:\n\n.. code-block:: python\n\n    # vanilla Python\n    from statistics import mean # Only in Python \u003e=3.4\n    women_ages = [\n        user['age'] for user in users\n        if user['gender'] == 'female'\n    ]\n    women_average_age = mean(women_ages)\n    minimum_woman_age = min(women_ages)\n\n    # lifter\n    results = manager.filter(User.gender == 'female')\\\n                     .aggregate((User.age, mean), (User.age, min))\n\nAs you can see, lifter's version is shorter and more readable than vanilla Python.\nIt's also less error prone, especially if you're writing really complex queries,\nand quite familiar if you've already used an ORM.\n\nWanna know more? Have a look at the documentation_!\n\n.. _documentation: http://lifter.readthedocs.org\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagateblue%2Flifter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagateblue%2Flifter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagateblue%2Flifter/lists"}