Skip to content
$ pip install pythonql

An integrated query language for Python.

Integrated query language for Python

Query your data right inside Python

The easiest way to work with your data in Python

We have taken the best from query languages such as SQL, XQuery and JSONiq and added it all to Python. Run powerful declarative queries against databases, files, JSON, XML, Pandas data frames and your own collections, all from ordinary Python code.

customer_journey.py
#coding: pythonql
from cust_journey_data import cust_journeys

res = [
   select (state, len(balance) as n_customers)
   for cj in cust_journeys
   let balance = sum(deposits) - sum(withdrawals)
   where balance > 300
   group by new.client_data.address.state as state
]

What PythonQL is

One query language for every data source

PythonQL lets you query files, databases, XML and JSON data, Pandas data frames and any collection. Install it with a single command, mark a file as PythonQL and start writing queries without changing the way the rest of your project works.

Declarative by design

SQL, XQuery and JSONiq features meet Python. Express grouping, joins, nesting and analytics as one readable query instead of pages of loops.

Any data source

Files, relational databases, XML and JSON documents, Pandas data frames and plain collections are all first class citizens of the same language.

Nothing gets in the way

Install with pip, mark a source file with #coding: pythonql, and your existing Python code keeps working exactly as before.

pip install pythonql
One command install, with pythonql3 for Python 3
#coding: pythonql
Opt in one file at a time
SQL + XQuery + JSONiq
Three proven languages in one

Detailed demonstration

Read, run and edit real queries

The web demo walks through four data science scenarios. Each one is broken into small queries you can inspect line by line, and the code behind every result is shown in full.

A PythonQL query shown in the web demo editor Analytical result table produced by a PythonQL query