cycquery
cycquery is a tool for querying relational databases using a simple Python API. It is specifically developed to query
Electronic Health Record (EHR) databases. The tool is a wrapper around SQLAlchemy and can be used
to write SQL-like queries in Python, including joins, conditions, groupby aggregation and many more.
🐣 Getting Started
Installing cycquery using pip
python3 -m pip install cycquery
Query postgresql database
from cycquery import DatasetQuerier
import cycquery.ops as qo
querier = DatasetQuerier(
dbms="postgresql",
port=5432,
host="localhost",
database="dbname",
user="usename",
password="password",
)
# List all tables.
querier.list_tables()
# Get some table.
table = querier.schema.sometable()
# Filter based on some condition (e.g. substring match).
table = table.ops(qo.ConditionSubstring("col1", "substr"))
# Run query to get data as a pandas dataframe.
df = table.run()
# Create a sequential list of operations to perform on the query.
ops = qo.Sequential(
qo.ConditionIn("col2", [1, 2]),
qo.DropNulls("col3"),
qo.Distinct("col1")
)
table = table.ops(ops)
# Run query to get data as a pandas dataframe.
df = table.run()
🧑🏿💻 Developing
Using poetry
The development environment can be set up using poetry. Hence, make sure it is installed and then run:
python3 -m poetry install
source $(poetry env info --path)/bin/activate
In order to install dependencies for testing (codestyle, unit tests, integration tests), run:
python3 -m poetry install --with test
API documentation is built using Sphinx and can be locally built by:
python3 -m poetry install --with docs
cd docs
make html SPHINXOPTS="-D nbsphinx_allow_errors=True"
Contributing
Contributing to cycquery is welcomed.
See Contributing for
guidelines.
📚 Documentation
Metadata
Release files for cycquery 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| cycquery-0.1.8.tar.gz | 44.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cycquery-0.1.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 96.0 kB
Release files / cycquery-0.1.8.tar.gz
| Download URL | cycquery-0.1.8.tar.gz |
|---|---|
| Size | 44.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bfb178774f41c10ec207167dedc95c7588fdfc44d9a227d8ccde4b900623130d
|
|
BLAKE2b-256 checksum How to use checksums |
d78025c67ecd8830d54882db1baff8fb495453bd754444bb4e5cc089a7596370
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Release files / cycquery-0.1.8-py3-none-any.whl
| Download URL | cycquery-0.1.8-py3-none-any.whl |
|---|---|
| Size | 51.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d53fcd4273025ef7f6a5f40825bf359511e578790eee630835b8557ff2d16831
|
|
BLAKE2b-256 checksum How to use checksums |
7c48d8dd22f6be9b1f09a71b190a0d65c35536ea79c735ac397b45081d5b76bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Security for cycquery 0.1.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.