{"id":28155910,"url":"https://github.com/imryche/litequery","last_synced_at":"2025-05-15T07:16:40.837Z","repository":{"id":246946661,"uuid":"819556067","full_name":"imryche/litequery","owner":"imryche","description":" A minimalist SQLite library for Python","archived":false,"fork":false,"pushed_at":"2025-02-04T20:51:29.000Z","size":50,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-06T06:05:19.315Z","etag":null,"topics":["aiohttp","asyncio","fastapi","orm","python","python3","sql","sqlite","sqlite-database","sqlite3","starlette"],"latest_commit_sha":null,"homepage":"","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/imryche.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":"2024-06-24T18:40:13.000Z","updated_at":"2025-02-04T20:51:00.000Z","dependencies_parsed_at":"2024-07-06T00:24:15.113Z","dependency_job_id":"8d06ce0f-9088-41e3-8fbd-9b61dbd0bfe8","html_url":"https://github.com/imryche/litequery","commit_stats":null,"previous_names":["imryche/litequery"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imryche%2Flitequery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imryche%2Flitequery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imryche%2Flitequery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imryche%2Flitequery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imryche","download_url":"https://codeload.github.com/imryche/litequery/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254292118,"owners_count":22046428,"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":["aiohttp","asyncio","fastapi","orm","python","python3","sql","sqlite","sqlite-database","sqlite3","starlette"],"created_at":"2025-05-15T07:14:49.490Z","updated_at":"2025-05-15T07:16:40.824Z","avatar_url":"https://github.com/imryche.png","language":"Python","readme":"# Litequery\n\nLitequery is a minimalist library for interacting with SQLite in Python. It lets\nyou define your queries once and call them as methods. No ORM bloat, just raw\nSQL power, with the flexibility to operate in both asynchronous and synchronous\nmodes.\n\n## Why Litequery?\n\n- **Simplicity**: Define SQL queries in `.sql` files. No complex ORM layers.\n- **Async first**: Built for modern async Python, but also supports synchronous\n  operations for traditional use cases.\n- **Flexible**: Supports different SQL operations seamlessly.\n\n## Installation\n\n```\npip install litequery\n```\n\n## Getting Started\n\n### Define Your Queries\n\nCreate a `queries.sql` file. Name your queries using comments and write them in\npure SQL.\n\n```sql\n-- name: get_all_users\nSELECT * FROM users;\n\n-- name: get_user_by_id^\nSELECT * FROM users WHERE id = :id;\n\n-- name: get_last_user_id$\nSELECT MAX(id) FROM users;\n\n-- name: insert_user\u003c!\nINSERT INTO users (name, email) VALUES (:name, :email);\n\n-- name: delete_all_users!\nDELETE FROM users;\n```\n\n### Using Your Queries\n\nDefine your database and queries, and then call them as methods. Choose async or\nsync setup based on your needs. It's as straightforward as it sounds.\n\n```python\nimport litequery\nimport asyncio\n\n\nasync def main():\n    lq = litequery.setup(\"database.db\", \"queries.sql\", use_async=True)\n    await lq.connect()\n\n    user_id = await lq.insert_user(name=\"Alice\", email=\"alice@example.com\")\n    print(user_id)\n\n    users = await lq.get_all_users()\n    print(users)\n\n    user = await lq.get_user_by_id(id=user_id)\n    print(user)\n\n    rows_count = await lq.delete_all_users()\n\n    await lq.disconnect()\n\n\nasyncio.run(main())\n```\n\n### Transaction Support\n\nLitequery also supports transactions in both async and sync contexts, allowing\nyou to execute multiple queries atomicaly.\n\n```python\nimport litequery\nimport asyncio\n\n\nasync def main():\n    lq = litequery.setup(\"database.db\", \"queries.sql\")\n    await lq.connect()\n\n    try:\n        async with lq.transaction():\n            await lq.insert_user(name=\"Charlie\", email=\"charlie@example.com\")\n            raise Exception(\"Force rollback\")\n            await lq.insert_user(name=\"Eve\", email=\"eve@example.com\")\n    except Exception:\n        print(\"Transaction failed\")\n\n    users = await lq.get_all_users()\n    print(users)\n\n    await lq.disconnect()\n\n\nasyncio.run(main())\n\n```\n\n## Wrapping Up\n\nLitequery is all about simplicity and efficiency. Why wrestle with bloated ORMs\nwhen you can have raw SQL power? If you think there's a better way or have\nsuggestions, let's hear them. Happy querying!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimryche%2Flitequery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimryche%2Flitequery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimryche%2Flitequery/lists"}