Skip to main content

Convenience wrapper for exonware-xwquery - provides 'import xwquery' alias

Project description

xwquery

Company: eXonware.com

Author: eXonware Backend Team

Email: connect@exonware.com

Query and transform native Python data structures with one API: SQL-style scripts, graph patterns, aggregations, and 35+ alternate surface syntaxes (Cypher, GraphQL, JMESPath, and others). It works directly with dictionaries, lists, and mixed in-memory structures; xwnode, xwdata, and xwentity integrations are optional add-ons when you want deeper stack features.

📦 Install

pip install exonware-xwquery

pip install exonware-xwquery[lazy]

pip install exonware-xwquery[full]

🚀 Basic usage

from exonware.xwquery import XWQuery



data = {'users': [

    {'name': 'Alice', 'age': 30, 'city': 'NYC'},

    {'name': 'Bob', 'age': 25, 'city': 'LA'},

    {'name': 'Charlie', 'age': 35, 'city': 'NYC'}

]}



result = XWQuery.execute("""

    SELECT name, age

    FROM users

    WHERE age > 25 AND city = 'NYC'

""", data)



print(result)

# [{'name': 'Alice', 'age': 30}, {'name': 'Charlie', 'age': 35}]

✨ What you get

  • Broad operation set - Core CRUD (SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP), filtering (WHERE, FILTER, LIKE, IN, RANGE, …), aggregation (GROUP BY, HAVING, SUM, COUNT, …), graph helpers (MATCH, PATH, …), and advanced pieces (JOIN, UNION, WITH, WINDOW, PIPE, …).

  • Many input languages - Strategies for SQL-family dialects, Cypher/Gremlin/SPARQL/GraphQL, document and log query languages (MQL, Elasticsearch DSL, PromQL, Flux, …), and more. Parse or convert between them where supported.

  • Structure-aware execution - The engine can adapt work to linear, tree, graph, or hybrid shapes when the backend exposes that metadata.

linear_data = [1, 2, 3, 4, 5]

tree_data = {'a': 1, 'b': 2, 'c': 3}

graph_data = {'nodes': [...], 'edges': [...]}



XWQuery.execute("SELECT * WHERE value > 2", linear_data)

XWQuery.execute("SELECT * WHERE key BETWEEN 'a' AND 'c'", tree_data)

XWQuery.execute("MATCH (n)-[r]->(m)", graph_data)

📄 Script examples

SELECT name, email, age FROM users WHERE age >= 18;



SELECT department, COUNT(*) AS employee_count, AVG(salary) AS avg_salary

FROM employees

GROUP BY department

HAVING avg_salary > 50000;



MATCH (u:User)-[:FRIENDS_WITH]->(f:User)

WHERE u.age > 25

RETURN u.name, f.name;

🔄 Format conversion

sql_query = "SELECT id, name FROM users WHERE age > 25"

graphql = XWQuery.convert(sql_query, from_format='sql', to_format='graphql')



cypher_query = "MATCH (u:User)-[:WORKS_AT]->(c:Company) RETURN u.name, c.name"

sql = XWQuery.convert(cypher_query, from_format='cypher', to_format='sql')



any_query = XWQuery.parse(query_string)

target_format = any_query.to_format('mongodb')

🔗 Stack integration

xwnode

from exonware.xwnode import XWNode

from exonware.xwquery import XWQuery



node = XWNode.from_native({'users': [...]})

result = XWQuery.execute("SELECT * FROM users WHERE active = true", node)

xwdata

from exonware.xwdata import XWData

from exonware.xwquery import XWQuery



data = XWData.load('users.json')

filtered = XWQuery.execute("SELECT * WHERE age > 18", data)

filtered.save('adults.xml')

xwentity

from exonware.xwentity import XWEntity

from exonware.xwquery import XWQuery



class User(XWEntity):

    name: str

    age: int

    email: str



users = XWQuery.execute("SELECT * FROM User WHERE age > 18")

🌐 Ecosystem functional contributions

xwquery provides query execution; sibling XW libraries provide data shapes, domain contracts, and persistence targets that those queries operate on.

You can use xwquery standalone over native Python data structures without the full XW stack.

Broader XW integration is optional and mainly intended for enterprise and mission-critical query infrastructure where unified storage/schema/domain contracts are required.

| Supporting XW lib | What it provides to xwquery workflows | Functional requirement it satisfies |

|------|----------------|----------------|

| XWNode | Graph/tree/list strategy abstractions and structural metadata. | Shape-aware execution planning across linear, tree, and graph data. |

| XWData | Multi-format data ingestion/export around query execution. | Querying heterogeneous input/output formats with one pipeline. |

| XWEntity | Entity/domain model surfaces that can be queried directly. | Domain-level querying rather than raw structure-only filtering. |

| XWStorage | Backend persistence/query integration for stored datasets. | Query execution against durable data, not only in-memory objects. |

| XWSchema | Optional schema validation before/after query transformations. | Safer transformations and contract compliance in pipelines. |

| XWSystem | Shared runtime and utility infrastructure used by parsers/executors. | Consistent execution behavior and lower operational duplication. |

Competitive edge: xwquery unifies many query syntaxes while remaining tightly connected to structure, schema, and storage layers in the same ecosystem.

📖 Docs

🛠️ Development

pip install -e .

python tests/runner.py

python tests/runner.py --core

python tests/runner.py --unit

python tests/runner.py --integration

📜 License

Apache-2.0 - see LICENSE.

🌐 Ecosystem

⏱️ Async Support

  • xwquery includes asynchronous execution paths in production code.

  • Source validation: 50 async def definitions and 24 await usages under src/.

  • Use async APIs for I/O-heavy or concurrent workloads to improve throughput and responsiveness.

Version: 0.9.0.16 | Updated: 25-Apr-2026

Built with ❤️ by eXonware.com - Revolutionizing Python Development Since 2025

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xwquery-0.9.0.16.tar.gz (499.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xwquery-0.9.0.16-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file xwquery-0.9.0.16.tar.gz.

File metadata

  • Download URL: xwquery-0.9.0.16.tar.gz
  • Upload date:
  • Size: 499.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for xwquery-0.9.0.16.tar.gz
Algorithm Hash digest
SHA256 11d744fe7833932028669e3200b7c8c0f88dbb061c6aa7611351538de459663b
MD5 9b462192b203947e001d872cc4288873
BLAKE2b-256 dd2b26f5d7e55975190168d5653db7b0480f368509924bcc1658e082ddba7fb5

See more details on using hashes here.

File details

Details for the file xwquery-0.9.0.16-py3-none-any.whl.

File metadata

  • Download URL: xwquery-0.9.0.16-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for xwquery-0.9.0.16-py3-none-any.whl
Algorithm Hash digest
SHA256 5514c5552ed099d779570b4862aeeb6b6058aa7868043cb08651cfc8e059f8d5
MD5 81c947fbd6833f46bc14e72498f0078c
BLAKE2b-256 39abaf25fc0ea726fd37ccf340af3dce7d28596d7a6cf3b7771a087bcc187c91

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page