{"id":20159616,"url":"https://github.com/co0lc0der/simple-query-builder-python","last_synced_at":"2025-04-09T23:36:29.178Z","repository":{"id":58836867,"uuid":"533646247","full_name":"co0lc0der/simple-query-builder-python","owner":"co0lc0der","description":"A simple SQL Query Builder Python module","archived":false,"fork":false,"pushed_at":"2025-02-09T15:36:15.000Z","size":81,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T01:25:24.804Z","etag":null,"topics":["database","python","python-oop","python3","query-builder","sql","sqlite3"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/simple-query-builder/","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/co0lc0der.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2022-09-07T07:01:25.000Z","updated_at":"2025-03-06T07:05:56.000Z","dependencies_parsed_at":"2024-11-13T07:28:36.922Z","dependency_job_id":"7698ebf6-c1fd-42e0-90c8-d512fc38cf86","html_url":"https://github.com/co0lc0der/simple-query-builder-python","commit_stats":{"total_commits":54,"total_committers":2,"mean_commits":27.0,"dds":0.01851851851851849,"last_synced_commit":"5c82e4801c8f1a9412102fa51c98de875ae146a6"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co0lc0der%2Fsimple-query-builder-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co0lc0der%2Fsimple-query-builder-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co0lc0der%2Fsimple-query-builder-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/co0lc0der%2Fsimple-query-builder-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/co0lc0der","download_url":"https://codeload.github.com/co0lc0der/simple-query-builder-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248130872,"owners_count":21052816,"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":["database","python","python-oop","python3","query-builder","sql","sqlite3"],"created_at":"2024-11-14T00:09:12.317Z","updated_at":"2025-04-09T23:36:29.166Z","avatar_url":"https://github.com/co0lc0der.png","language":"Python","readme":"# QueryBuilder python module\n\n[![Latest Version](https://img.shields.io/github/release/co0lc0der/simple-query-builder-python?color=orange\u0026style=flat-square)](https://github.com/co0lc0der/simple-query-builder-python/release)\n![GitHub repo size](https://img.shields.io/github/repo-size/co0lc0der/simple-query-builder-python?label=size\u0026style=flat-square)\n[![GitHub license](https://img.shields.io/github/license/co0lc0der/simple-query-builder-python?style=flat-square)](https://github.com/co0lc0der/simple-query-builder-python/blob/main/LICENSE.md)\n![Python 3.7, 3.8, 3.9, 3.10, 3.11, 3.12](https://img.shields.io/pypi/pyversions/simple-query-builder?color=blueviolet\u0026style=flat-square)\n![PyPI](https://img.shields.io/pypi/v/simple-query-builder?color=yellow\u0026style=flat-square)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/simple-query-builder?color=darkgreen\u0026style=flat-square)\n\nThis is a small easy-to-use module for working with a database. It provides some public methods to compose SQL queries and manipulate data. Each SQL query is prepared and safe. QueryBuilder fetches data to _dictionary_ by default. At present time the component supports SQLite (file or memory).\n\n## Contributing\n\nBug reports and/or pull requests are welcome\n\n## License\n\nThe module is available as open source under the terms of the [MIT license](https://github.com/co0lc0der/simple-query-builder-python/blob/main/LICENSE.md)\n\n## Installation\n\nInstall the current version with [PyPI](https://pypi.org/project/simple-query-builder):\n\n```bash\npip install simple-query-builder\n```\n\nOr from Github:\n```bash\npip install https://github.com/co0lc0der/simple-query-builder-python/archive/main.zip\n```\n## How to use\n### Import the module and init `QueryBuilder` with `Database()`\n```python\nfrom simple_query_builder import *\n\nqb = QueryBuilder(DataBase(), 'my_db.db')\n\n# or DB in memory\nqb = QueryBuilder(DataBase(), ':memory:')\n```\n### Usage examples\n#### Select all rows from a table\n```python\nresults = qb.select('users').all()\n```\nResult query\n```sql\nSELECT * FROM `users`;\n```\n#### Select rows with two conditions\n```python\nresults = qb.select('users').where([['id', '\u003e', 1], 'and', ['group_id', '=', 2]]).all()\n```\nResult query\n```sql\nSELECT * FROM `users` WHERE (`id` \u003e 1) AND (`group_id` = 2);\n```\n#### Update a row\n```python\nqb.update('users', {\n        'username': 'John Doe',\n        'status': 'new status'\n    })\\\n    .where([['id', '=', 7]])\\\n    .limit()\\\n    .go()\n```\nResult query\n```sql\nUPDATE `users` SET `username` = 'John Doe', `status` = 'new status'\nWHERE `id` = 7 LIMIT 1;\n```\nMore examples you can find in [documentation](https://github.com/co0lc0der/simple-query-builder-python/blob/main/docs/index.md)\n\n## ToDo\nI'm going to add the next features into future versions\n- write more unit testes\n- add subqueries for QueryBuilder\n- add `BETWEEN`\n- add `WHERE EXISTS`\n- add TableBuilder class (for beginning `CREATE TABLE`, move `qb.drop()` and `qb.truncate()` into it)\n- add MySQL support\n- add PostgreSQL support\n- add `WITH`\n- and probably something more\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fco0lc0der%2Fsimple-query-builder-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fco0lc0der%2Fsimple-query-builder-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fco0lc0der%2Fsimple-query-builder-python/lists"}