{"id":21665004,"url":"https://github.com/carlossilva2/knexpy","last_synced_at":"2026-05-18T18:31:35.893Z","repository":{"id":56849549,"uuid":"517138744","full_name":"carlossilva2/Knexpy","owner":"carlossilva2","description":"An abstraction for SQLite3 based on Knexjs","archived":false,"fork":false,"pushed_at":"2022-08-20T23:24:12.000Z","size":658,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-27T11:20:38.761Z","etag":null,"topics":["abstraction","human-readable","knex","module","python3","sql","sqlite3"],"latest_commit_sha":null,"homepage":"https://knexpy.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/carlossilva2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":["https://www.buymeacoffee.com/cmsilva"]}},"created_at":"2022-07-23T18:46:46.000Z","updated_at":"2024-11-28T19:01:14.000Z","dependencies_parsed_at":"2022-08-18T21:50:08.512Z","dependency_job_id":null,"html_url":"https://github.com/carlossilva2/Knexpy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlossilva2%2FKnexpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlossilva2%2FKnexpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlossilva2%2FKnexpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlossilva2%2FKnexpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carlossilva2","download_url":"https://codeload.github.com/carlossilva2/Knexpy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244562047,"owners_count":20472574,"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":["abstraction","human-readable","knex","module","python3","sql","sqlite3"],"created_at":"2024-11-25T10:48:33.288Z","updated_at":"2026-05-18T18:31:35.807Z","avatar_url":"https://github.com/carlossilva2.png","language":"Python","funding_links":["https://www.buymeacoffee.com/cmsilva"],"categories":[],"sub_categories":[],"readme":"# Knexpy\n\n\u003ca href=\"https://github.com/carlossilva2/Knexpy/blob/main/LICENSE\" target=\"blank\"\u003e\u003cimg src=\"https://img.shields.io/github/license/carlossilva2/Knexpy?style=round-square\u0026color=green\" alt=\"Knexpy License\" /\u003e\u003c/a\u003e\n[![Downloads](https://pepy.tech/badge/knexpy)](https://pepy.tech/project/knexpy)\n[![Supported Versions](https://img.shields.io/pypi/pyversions/knexpy.svg)](https://pypi.org/project/knexpy)\n[![Documentation Status](https://readthedocs.org/projects/knexpy/badge/?version=latest)](https://knexpy.readthedocs.io/en/latest/?badge=latest)\n[![Black](https://img.shields.io/badge/code%20style-black-000000)](https://github.com/psf/black)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\u0026logoColor=white)](https://github.com/pre-commit/pre-commit)\n\u003ca href=\"https://www.buymeacoffee.com/cmsilva\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/default-orange.png\" alt=\"Buy Me A Coffee\" height=\"23\" width=\"100\" style=\"border-radius:5px\" /\u003e\u003c/a\u003e\n\nA query builder for SQLite3 based on Knexjs\n\n## Features\n\n* Transactions\n* Type Checking\n* Bulk Insert\n* JSON mapping\n\nYou can report bugs and discuss feature on the [GitHub issues page](https://github.com/carlossilva2/Knexpy/issues).\nFor more detailed information check [Readthedocs](https://knexpy.readthedocs.io/)\n\n## Examples\n\n### Creating a Table\n\n```python\nfrom Knexpy import Knex, Field\n\ndb = Knex(\"\u003cDatabase File Name/Path\u003e\")\n\ndb.table(\n    \"c\",\n    [\n        Field.integer(\"field\"),\n    ],\n    not_exists=False,\n)\n\ndb.table(\n    \"t\",\n    [\n        Field.varchar(\"field\"), # Default size: 255\n        Field.varchar(\"field2\"),\n        Field.varchar(\"field3\"),\n        Field.foreign_key(\"field4\", \"c\", \"id\"),\n    ],\n    not_exists=False, # IF NOT EXISTS clause. Defaults to True\n)\n```\n\n\u003e When creating a table the fields `id`, `created_at`, `modified_at` are automatically generated.\n\u003e The `id` field is a hash based on the information of the Row\n\n### Basic Select\n\n```python\nfrom Knexpy import Knex\n\ndb = Knex(\"\u003cDatabase File Name/Path\u003e\")\n\nquery = (\n    db.select(\"id\", \"field\", \"field2\", [\"field3\", \"test\"],...) # List type on select acts as an alias\n    .from_(\"t\")\n    .where(\"field\", \"=\", \"12345\")\n    .order_by(\"id\")\n)\n\nquery.query() # Returns data as JSON\nquery.query(False) # Returns data as tuples\n```\n\n### Select with Subquery\n\n```python\nfrom Knexpy import Knex\n\ndb = Knex(\"\u003cDatabase File Name/Path\u003e\")\n\nquery = (\n    db.select(\"id\", \"field\", \"field2\", [\"field3\", \"test\"],...)\n    .from_(\"t\")\n    .where(\"field\", \"=\", \"12345\")\n    .where(\n        \"field4\",\n        \"=\",\n        db.subquery().select(\"id\").from_(\"c\").where(\"field\", \"=\", 12345),\n        join_type=\"OR\", # If attribute not present defaults to \"AND\".\n    )\n    .order_by(\"id\")\n)\n\nquery.query() # Returns data as JSON\n```\n\n### Insert JSON Data\n\n```python\nfrom Knexpy import Knex\n\ndb = Knex(\"\u003cDatabase File Name/Path\u003e\", type_check=True) # type_check enables type checking (duh) when inserting/updating data\n\ndb.insert_json(\"\u003ctable\u003e\", {\n    \"field\": \"1\",\n    \"field2\": \"2\",\n    \"field3\": \"3\"\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarlossilva2%2Fknexpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarlossilva2%2Fknexpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarlossilva2%2Fknexpy/lists"}