[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/edgeql-qb)](https://badge.fury.io/py/edgeql-qb)
[![PyPI version](https://badge.fury.io/py/edgeql-qb.svg)](https://badge.fury.io/py/edgeql-qb)
[![Tests](https://github.com/Pentusha/edgeql-qb/actions/workflows/tests.yml/badge.svg)](https://github.com/Pentusha/edgeql-qb/actions/workflows/tests.yml)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=Pentusha_edgeql-qb&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=Pentusha_edgeql-qb)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=Pentusha_edgeql-qb&metric=coverage)](https://sonarcloud.io/summary/new_code?id=Pentusha_edgeql-qb)
# EdgeQL Query Builder
Query builder for EdgeDB
## Description
* This project is currently in pre-alpha status, meaning that it is not yet production-ready and may be buggy and unstable.
* Please note that this project is not affiliated with the official developers of EdgeDB.
* Additionally, it is important to know that this project only supports a small part of the EdgeDB syntax.
* The library does not include any code for connecting to the database or executing queries.
* It also does not provide database introspection, so it will not check for typos in column names. What you write is what you get.
* Python version 3.10 or higher is required to use this library, and there are currently no plans for backporting to earlier versions.
* There are no external dependencies, including EdgeDB itself.
# Usage examples
Many examples of queries are given in the [documentation](https://pentusha.github.io/edgeql-qb/queries) directory.
```python
from edgeql_qb import EdgeDBModel
from edgeql_qb.types import int16
from edgedb.blocking_client import create_client
client = create_client()
Movie = EdgeDBModel('Movie')
Person = EdgeDBModel('Person')
insert = Movie.insert.values(
title='Blade Runner 2049',
year=int16(2017),
director=(
Person.select()
.where(Person.c.id == director_id)
.limit1
),
actors=Person.insert.values(
first_name='Harrison',
last_name='Ford',
),
).build()
select = (
Movie.select(
Movie.c.title,
Movie.c.year,
Movie.c.director(
Movie.c.director.first_name,
Movie.c.director.last_name,
),
Movie.c.actors(
Movie.c.actors.first_name,
Movie.c.actors.last_name,
),
)
.where(Movie.c.title == 'Blade Runner 2049')
.build()
)
delete = Movie.delete.where(Movie.c.title == 'Blade Runner 2049').build()
decade = (Movie.c.year // 10).label('decade')
group = Movie.group().using(decade).by(decade).build()
client.query(insert.query, **insert.context)
result = client.query(select.query, **select.context)
movies_by_decade = client.query(group.query, **group.context)
client.query(delete.query, **delete.context)
```
## Status
- Queries:
- [x] select
- [x] [nested shapes](https://www.edgedb.com/tutorial/nested-structures/shapes)
- [x] filters for nested shapes
- [x] order by for nested shapes
- [x] limit/offset for nested shapes
- [x] aggregations for nested shapes
- [x] function calls
- [x] computed fields
- [x] filters
- [x] filter by nested paths
- [x] limit & offset
- [x] order by
- [ ] [backlinks](https://www.edgedb.com/docs/edgeql/paths#backlinks)
- [x] [subqueries](https://www.edgedb.com/tutorial/nested-structures/shapes/subqueries)
- [ ] [polymorphic fields](https://www.edgedb.com/tutorial/nested-structures/polymorphism)
- [ ] [link properties](https://www.edgedb.com/docs/edgeql/paths#link-properties) (@notation)
- [ ] [detached](https://github.com/edgedb/edgedb/blob/master/docs/reference/edgeql/with.rst)
- [x] group
- [x] columns
- [x] using
- [x] by
- [x] function calls
- [x] update
- [x] function calls
- [x] nested queries
- [x] delete
- [x] delete without filters
- [x] function calls
- [x] limit & offset
- [x] order by
- [x] insert
- [x] [nested inserts](https://www.edgedb.com/docs/edgeql/insert#nested-inserts)
- [X] [conditional inserts](https://www.edgedb.com/tutorial/data-mutations/upsert/conditional-inserts)
- [x] [idempotent insert](https://www.edgedb.com/tutorial/data-mutations/upsert/idempotent-insert)
- [x] [select-or-insert](https://www.edgedb.com/tutorial/data-mutations/upsert/select-or-insert)
- [x] function calls
- [x] positional arguments
- [ ] keyword arguments
- [x] [with block](https://www.edgedb.com/tutorial/nested-structures/shapes/with-block)
- [x] with literal
- [x] with subquery
- [x] with module + closure
- [ ] with x := subquery select x
- [ ] with x := subquery group x
- [ ] with x := subquery update x
- [ ] with x := Type.column
- [ ] if statements
- [ ] [globals](https://www.edgedb.com/docs/datamodel/globals#globals)
- [ ] [for statements](https://www.edgedb.com/docs/edgeql/paths#link-properties)
- [ ] union statements
- [ ] queries without models, like select [1,2,3]
- Types:
- [x] type casts
- [ ] cal::date_duration
- [ ] cal::relative_duration
- [ ] std::array
- [ ] std::json
- [ ] std::range
- [ ] std::set
- [ ] std::tuple
- [x] cal::local_date
- [x] cal::local_date
- [x] cal::local_datetime
- [x] cal::local_time
- [x] std::bigint
- [x] std::bool
- [x] std::bytes
- [x] std::datetime
- [x] std::decimal
- [x] std::duration
- [x] std::float32
- [x] std::float64
- [x] std::int16
- [x] std::int32
- [x] std::int64
- [x] std::str
- [x] std::uuid
- Functions
- [x] cal
- [x] math
- [x] std
- [x] sys
Raw data
{
"_id": null,
"home_page": "https://github.com/Pentusha/edgeql-qb",
"name": "edgeql_qb",
"maintainer": "Ivan Larin",
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": "pentusha@gmail.com",
"keywords": "edgedb, edgeql",
"author": "Ivan Larin",
"author_email": "pentusha@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/ce/e6/f31f73772ef2e7e0b15b3482184f92e0e2eb929fd34e124798451911207d/edgeql_qb-0.4.6.tar.gz",
"platform": null,
"description": "[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/edgeql-qb)](https://badge.fury.io/py/edgeql-qb)\n[![PyPI version](https://badge.fury.io/py/edgeql-qb.svg)](https://badge.fury.io/py/edgeql-qb)\n[![Tests](https://github.com/Pentusha/edgeql-qb/actions/workflows/tests.yml/badge.svg)](https://github.com/Pentusha/edgeql-qb/actions/workflows/tests.yml)\n[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=Pentusha_edgeql-qb&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=Pentusha_edgeql-qb)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=Pentusha_edgeql-qb&metric=coverage)](https://sonarcloud.io/summary/new_code?id=Pentusha_edgeql-qb)\n\n# EdgeQL Query Builder\n\nQuery builder for EdgeDB\n\n## Description\n* This project is currently in pre-alpha status, meaning that it is not yet production-ready and may be buggy and unstable.\n* Please note that this project is not affiliated with the official developers of EdgeDB.\n* Additionally, it is important to know that this project only supports a small part of the EdgeDB syntax.\n* The library does not include any code for connecting to the database or executing queries.\n* It also does not provide database introspection, so it will not check for typos in column names. What you write is what you get.\n* Python version 3.10 or higher is required to use this library, and there are currently no plans for backporting to earlier versions.\n* There are no external dependencies, including EdgeDB itself.\n\n# Usage examples\nMany examples of queries are given in the [documentation](https://pentusha.github.io/edgeql-qb/queries) directory.\n\n```python\nfrom edgeql_qb import EdgeDBModel\nfrom edgeql_qb.types import int16\nfrom edgedb.blocking_client import create_client\n\n\nclient = create_client()\nMovie = EdgeDBModel('Movie')\nPerson = EdgeDBModel('Person')\n\ninsert = Movie.insert.values(\n title='Blade Runner 2049',\n year=int16(2017),\n director=(\n Person.select()\n .where(Person.c.id == director_id)\n .limit1\n ),\n actors=Person.insert.values(\n first_name='Harrison',\n last_name='Ford',\n ),\n).build()\n\n\nselect = (\n Movie.select(\n Movie.c.title,\n Movie.c.year,\n Movie.c.director(\n Movie.c.director.first_name,\n Movie.c.director.last_name,\n ),\n Movie.c.actors(\n Movie.c.actors.first_name,\n Movie.c.actors.last_name,\n ),\n )\n .where(Movie.c.title == 'Blade Runner 2049')\n .build()\n)\n\ndelete = Movie.delete.where(Movie.c.title == 'Blade Runner 2049').build()\n\ndecade = (Movie.c.year // 10).label('decade')\ngroup = Movie.group().using(decade).by(decade).build()\n\nclient.query(insert.query, **insert.context)\nresult = client.query(select.query, **select.context)\n\nmovies_by_decade = client.query(group.query, **group.context)\n\nclient.query(delete.query, **delete.context)\n```\n\n## Status\n- Queries:\n - [x] select\n - [x] [nested shapes](https://www.edgedb.com/tutorial/nested-structures/shapes)\n - [x] filters for nested shapes\n - [x] order by for nested shapes\n - [x] limit/offset for nested shapes\n - [x] aggregations for nested shapes\n - [x] function calls\n - [x] computed fields\n - [x] filters\n - [x] filter by nested paths\n - [x] limit & offset\n - [x] order by\n - [ ] [backlinks](https://www.edgedb.com/docs/edgeql/paths#backlinks)\n - [x] [subqueries](https://www.edgedb.com/tutorial/nested-structures/shapes/subqueries)\n - [ ] [polymorphic fields](https://www.edgedb.com/tutorial/nested-structures/polymorphism)\n - [ ] [link properties](https://www.edgedb.com/docs/edgeql/paths#link-properties) (@notation)\n - [ ] [detached](https://github.com/edgedb/edgedb/blob/master/docs/reference/edgeql/with.rst)\n - [x] group\n - [x] columns\n - [x] using\n - [x] by\n - [x] function calls\n - [x] update\n - [x] function calls\n - [x] nested queries\n - [x] delete\n - [x] delete without filters\n - [x] function calls\n - [x] limit & offset\n - [x] order by\n - [x] insert\n - [x] [nested inserts](https://www.edgedb.com/docs/edgeql/insert#nested-inserts)\n - [X] [conditional inserts](https://www.edgedb.com/tutorial/data-mutations/upsert/conditional-inserts)\n - [x] [idempotent insert](https://www.edgedb.com/tutorial/data-mutations/upsert/idempotent-insert)\n - [x] [select-or-insert](https://www.edgedb.com/tutorial/data-mutations/upsert/select-or-insert)\n - [x] function calls\n - [x] positional arguments\n - [ ] keyword arguments\n - [x] [with block](https://www.edgedb.com/tutorial/nested-structures/shapes/with-block)\n - [x] with literal\n - [x] with subquery\n - [x] with module + closure\n - [ ] with x := subquery select x\n - [ ] with x := subquery group x\n - [ ] with x := subquery update x\n - [ ] with x := Type.column\n - [ ] if statements\n - [ ] [globals](https://www.edgedb.com/docs/datamodel/globals#globals)\n - [ ] [for statements](https://www.edgedb.com/docs/edgeql/paths#link-properties)\n - [ ] union statements\n - [ ] queries without models, like select [1,2,3]\n- Types:\n - [x] type casts\n - [ ] cal::date_duration\n - [ ] cal::relative_duration\n - [ ] std::array\n - [ ] std::json\n - [ ] std::range\n - [ ] std::set\n - [ ] std::tuple\n - [x] cal::local_date\n - [x] cal::local_date\n - [x] cal::local_datetime\n - [x] cal::local_time\n - [x] std::bigint\n - [x] std::bool\n - [x] std::bytes\n - [x] std::datetime\n - [x] std::decimal\n - [x] std::duration\n - [x] std::float32\n - [x] std::float64\n - [x] std::int16\n - [x] std::int32\n - [x] std::int64\n - [x] std::str\n - [x] std::uuid\n\n- Functions\n - [x] cal\n - [x] math\n - [x] std\n - [x] sys\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "EdgeQL Query Builder",
"version": "0.4.6",
"project_urls": {
"Homepage": "https://github.com/Pentusha/edgeql-qb",
"Repository": "https://github.com/Pentusha/edgeql-qb"
},
"split_keywords": [
"edgedb",
" edgeql"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0def7c4c423d4e516d6f691f28c7f58a68b52a30bc28fb166891878d83bf40fe",
"md5": "698797406950329e184340a55f2a7556",
"sha256": "6fc63c50626ad88d6297400b709a29f02ae4e8248cddaf206d4f6b023041f55a"
},
"downloads": -1,
"filename": "edgeql_qb-0.4.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "698797406950329e184340a55f2a7556",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 23811,
"upload_time": "2024-11-22T07:47:28",
"upload_time_iso_8601": "2024-11-22T07:47:28.261120Z",
"url": "https://files.pythonhosted.org/packages/0d/ef/7c4c423d4e516d6f691f28c7f58a68b52a30bc28fb166891878d83bf40fe/edgeql_qb-0.4.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cee6f31f73772ef2e7e0b15b3482184f92e0e2eb929fd34e124798451911207d",
"md5": "d260f9e288073d6d770eaea5a2e9930b",
"sha256": "f82c329bffdc46bb7d0f87329155922d953aac96490fb547bd74014e29569a07"
},
"downloads": -1,
"filename": "edgeql_qb-0.4.6.tar.gz",
"has_sig": false,
"md5_digest": "d260f9e288073d6d770eaea5a2e9930b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 17672,
"upload_time": "2024-11-22T07:47:29",
"upload_time_iso_8601": "2024-11-22T07:47:29.809442Z",
"url": "https://files.pythonhosted.org/packages/ce/e6/f31f73772ef2e7e0b15b3482184f92e0e2eb929fd34e124798451911207d/edgeql_qb-0.4.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-22 07:47:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Pentusha",
"github_project": "edgeql-qb",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "edgeql_qb"
}