{"id":19378156,"url":"https://github.com/almarklein/itemdb","last_synced_at":"2025-04-23T19:31:44.769Z","repository":{"id":47208413,"uuid":"270247565","full_name":"almarklein/itemdb","owner":"almarklein","description":"Easy transactional database for Python dicts, backed by SQLite","archived":false,"fork":false,"pushed_at":"2024-04-18T14:28:55.000Z","size":115,"stargazers_count":18,"open_issues_count":3,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-06T19:51:11.512Z","etag":null,"topics":["async","database","no-sql","sqlite"],"latest_commit_sha":null,"homepage":"https://itemdb.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/almarklein.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-07T08:51:31.000Z","updated_at":"2024-07-24T03:27:49.000Z","dependencies_parsed_at":"2024-06-19T03:02:24.990Z","dependency_job_id":null,"html_url":"https://github.com/almarklein/itemdb","commit_stats":{"total_commits":24,"total_committers":2,"mean_commits":12.0,"dds":"0.45833333333333337","last_synced_commit":"30e396da5301f7c2cb67cafa2096b85321349589"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/almarklein%2Fitemdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/almarklein%2Fitemdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/almarklein%2Fitemdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/almarklein%2Fitemdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/almarklein","download_url":"https://codeload.github.com/almarklein/itemdb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223932163,"owners_count":17227277,"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":["async","database","no-sql","sqlite"],"created_at":"2024-11-10T09:05:01.798Z","updated_at":"2024-11-10T09:05:02.430Z","avatar_url":"https://github.com/almarklein.png","language":"Python","readme":"[![PyPI Version](https://img.shields.io/pypi/v/itemdb.svg)](https://pypi.python.org/pypi/itemdb/)\n[![CI](https://github.com/almarklein/itemdb/workflows/CI/badge.svg)](https://github.com/almarklein/itemdb/actions)\n[![Documentation Status](https://readthedocs.org/projects/itemdb/badge/?version=latest)](https://itemdb.readthedocs.io/en/latest/?badge=latest)\n\n# itemdb\n\n\nThe itemdb library allows you to store and retrieve Python dicts in a\ndatabase on the local filesystem, in an easy, fast, and reliable way.\n\nBased on the rock-solid and ACID compliant SQLite, but with easy and\nexplicit transactions using a ``with`` statement. It provides a simple\nobject-based API, with the flexibility to store (JSON-compatible) items\nwith arbitrary fields, and add indices when needed.\n\nThis lib was originally part of the [TimeTurtle time tracker](https://timeturtle.app)\nand is also used in [MyPaaS](https://github.com/almarklein/mypaas).\n\n\n## Installation\n\n```\npip install itemdb\n```\n\n\n## Quick usage example\n\n```py\nimport itemdb\n\n# Open the database and make sure there is a table with appopriate indices\ndb = itemdb.ItemDB(\":memory:\")\ndb.ensure_table(\"persons\", \"!name\", \"age\")\n\n# Add some items to the db\nwith db:\n    db.put_one(\"persons\", name=\"Jane\", age=22)\n    db.put_one(\"persons\", name=\"John\", age=18, fav_number=7)\n    db.put(\"persons\", {\"name\": \"Guido\"}, {\"name\": \"Anne\", \"age\": 42})\n\n# Update an item\nwith db:\n    db.put_one(\"persons\", name=\"John\", age=19, fav_number=8)\n\n# Query items\ndb.count_all(\"persons\")  # -\u003e 4\ndb.select(\"persons\", \"age \u003e ?\", 20)  # -\u003e list of 2 items\n```\n\nSee the [guide](https://itemdb.readthedocs.io/en/latest/guide.html) for details.\n\n\n## Async\n\nThe `AsyncItemDB` class provides the same API, but async:\n\n```py\nimport itemdb\n\ndb = await itemdb.AsyncItemDB(\":memory:\")\nawait db.ensure_table(\"persons\", \"!name\", \"age\")\n\nasync with db:\n    await db.put_one(\"persons\", name=\"Jane\", age=22)\n\n...\n```\n\nAlternatively, a decorator is provided to turn a normal function into an async one\n(running in a separate thread).\n\n```py\n\n@asycify\ndef your_db_interaction_logic(...):\n    db = ItemDB(filename)\n    ...\n\nasync def your_async_code(...):\n    await your_db_interaction_logic(...)\n```\n\n\n## License\n\nMIT\n\n\n## Developers\n\n* Run `black .` to autoformat.\n* Run `flake8 . --max-line-length=99` to lint.\n* Run `pytest .` to run unit tests.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falmarklein%2Fitemdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falmarklein%2Fitemdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falmarklein%2Fitemdb/lists"}