cycquery


Namecycquery JSON
Version 0.1.7 PyPI version JSON
download
home_pagehttps://github.com/VectorInstitute/cycquery
SummaryA tool to query EHR databases
upload_time2024-04-18 16:19:06
maintainerNone
docs_urlNone
authorVector AI Engineering
requires_python<3.12,>=3.9
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            cycquery
--------------------------------------------------------------------------------

[![PyPI](https://img.shields.io/pypi/v/cycquery)](https://pypi.org/project/cycquery)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cycquery)
[![code checks](https://github.com/VectorInstitute/cycquery/actions/workflows/code_checks.yml/badge.svg)](https://github.com/VectorInstitute/cycquery/actions/workflows/code_checks.yml)
[![integration tests](https://github.com/VectorInstitute/cycquery/actions/workflows/integration_tests.yml/badge.svg)](https://github.com/VectorInstitute/cycquery/actions/workflows/integration_tests.yml)
[![docs](https://github.com/VectorInstitute/cycquery/actions/workflows/docs_deploy.yml/badge.svg)](https://github.com/VectorInstitute/cycquery/actions/workflows/docs_deploy.yml)
[![codecov](https://codecov.io/gh/VectorInstitute/cycquery/branch/main/graph/badge.svg)](https://codecov.io/gh/VectorInstitute/cycquery)
[![license](https://img.shields.io/github/license/VectorInstitute/cycquery.svg)](https://github.com/VectorInstitute/cycquery/blob/main/LICENSE)

``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](https://www.sqlalchemy.org/) 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

```bash
python3 -m pip install cycquery
```

### Query postgresql database

```python
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](https://python-poetry.org/docs/#installation). Hence, make sure it is
installed and then run:


```bash
python3 -m poetry install
source $(poetry env info --path)/bin/activate
```

In order to install dependencies for testing (codestyle, unit tests, integration tests),
run:

```bash
python3 -m poetry install --with test
```

API documentation is built using [Sphinx](https://www.sphinx-doc.org/en/master/) and
can be locally built by:

```bash
python3 -m poetry install --with docs
cd docs
make html SPHINXOPTS="-D nbsphinx_allow_errors=True"
```

### Contributing

Contributing to ``cycquery`` is welcomed.
See [Contributing](https://vectorinstitute.github.io/cycquery/api/contributing.html) for
guidelines.


## 📚 [Documentation](https://vectorinstitute.github.io/cycquery/)


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/VectorInstitute/cycquery",
    "name": "cycquery",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.12,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Vector AI Engineering",
    "author_email": "cyclops@vectorinstitute.ai",
    "download_url": "https://files.pythonhosted.org/packages/f0/c7/b244ec3135b7d1e4fc1cd8485c2f97b86a6db1ef11d7576b8b7675ea1c2b/cycquery-0.1.7.tar.gz",
    "platform": null,
    "description": "cycquery\n--------------------------------------------------------------------------------\n\n[![PyPI](https://img.shields.io/pypi/v/cycquery)](https://pypi.org/project/cycquery)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cycquery)\n[![code checks](https://github.com/VectorInstitute/cycquery/actions/workflows/code_checks.yml/badge.svg)](https://github.com/VectorInstitute/cycquery/actions/workflows/code_checks.yml)\n[![integration tests](https://github.com/VectorInstitute/cycquery/actions/workflows/integration_tests.yml/badge.svg)](https://github.com/VectorInstitute/cycquery/actions/workflows/integration_tests.yml)\n[![docs](https://github.com/VectorInstitute/cycquery/actions/workflows/docs_deploy.yml/badge.svg)](https://github.com/VectorInstitute/cycquery/actions/workflows/docs_deploy.yml)\n[![codecov](https://codecov.io/gh/VectorInstitute/cycquery/branch/main/graph/badge.svg)](https://codecov.io/gh/VectorInstitute/cycquery)\n[![license](https://img.shields.io/github/license/VectorInstitute/cycquery.svg)](https://github.com/VectorInstitute/cycquery/blob/main/LICENSE)\n\n``cycquery`` is a tool for querying relational databases using a simple Python API. It is specifically developed to query\nElectronic Health Record (EHR) databases. The tool is a wrapper around [SQLAlchemy](https://www.sqlalchemy.org/) and can be used\nto write SQL-like queries in Python, including joins, conditions, groupby aggregation and many more.\n\n## \ud83d\udc23 Getting Started\n\n### Installing cycquery using pip\n\n```bash\npython3 -m pip install cycquery\n```\n\n### Query postgresql database\n\n```python\nfrom cycquery import DatasetQuerier\nimport cycquery.ops as qo\n\n\nquerier = DatasetQuerier(\n    dbms=\"postgresql\",\n    port=5432,\n    host=\"localhost\",\n    database=\"dbname\",\n    user=\"usename\",\n    password=\"password\",\n)\n# List all tables.\nquerier.list_tables()\n\n# Get some table.\ntable = querier.schema.sometable()\n# Filter based on some condition (e.g. substring match).\ntable = table.ops(qo.ConditionSubstring(\"col1\", \"substr\"))\n# Run query to get data as a pandas dataframe.\ndf = table.run()\n\n# Create a sequential list of operations to perform on the query.\nops = qo.Sequential(\n\tqo.ConditionIn(\"col2\", [1, 2]),\n\tqo.DropNulls(\"col3\"),\n\tqo.Distinct(\"col1\")\n)\ntable = table.ops(ops)\n# Run query to get data as a pandas dataframe.\ndf = table.run()\n```\n\n## \ud83e\uddd1\ud83c\udfff\u200d\ud83d\udcbb Developing\n\n### Using poetry\n\nThe development environment can be set up using\n[poetry](https://python-poetry.org/docs/#installation). Hence, make sure it is\ninstalled and then run:\n\n\n```bash\npython3 -m poetry install\nsource $(poetry env info --path)/bin/activate\n```\n\nIn order to install dependencies for testing (codestyle, unit tests, integration tests),\nrun:\n\n```bash\npython3 -m poetry install --with test\n```\n\nAPI documentation is built using [Sphinx](https://www.sphinx-doc.org/en/master/) and\ncan be locally built by:\n\n```bash\npython3 -m poetry install --with docs\ncd docs\nmake html SPHINXOPTS=\"-D nbsphinx_allow_errors=True\"\n```\n\n### Contributing\n\nContributing to ``cycquery`` is welcomed.\nSee [Contributing](https://vectorinstitute.github.io/cycquery/api/contributing.html) for\nguidelines.\n\n\n## \ud83d\udcda [Documentation](https://vectorinstitute.github.io/cycquery/)\n\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "A tool to query EHR databases",
    "version": "0.1.7",
    "project_urls": {
        "Documentation": "https://vectorinstitute.github.io/cycquery/",
        "Homepage": "https://github.com/VectorInstitute/cycquery",
        "Repository": "https://github.com/VectorInstitute/cycquery"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2f31c76850176adf455295de1d32b3be40d6c82d2f05311d2387226f1ba11612",
                "md5": "e4165c95ffcc6c6a146cb5bb26fad4d5",
                "sha256": "34598b88ff8679b236cb0542af2c88e85f9d2244c619948755c64adc84e3ab33"
            },
            "downloads": -1,
            "filename": "cycquery-0.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e4165c95ffcc6c6a146cb5bb26fad4d5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.12,>=3.9",
            "size": 50888,
            "upload_time": "2024-04-18T16:19:04",
            "upload_time_iso_8601": "2024-04-18T16:19:04.433202Z",
            "url": "https://files.pythonhosted.org/packages/2f/31/c76850176adf455295de1d32b3be40d6c82d2f05311d2387226f1ba11612/cycquery-0.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f0c7b244ec3135b7d1e4fc1cd8485c2f97b86a6db1ef11d7576b8b7675ea1c2b",
                "md5": "6b3f69898624c40f889d43efd3f22a77",
                "sha256": "8b5371b67a1483becf3bc9520090ff39b884febac7d6b1243555be50e6bf4508"
            },
            "downloads": -1,
            "filename": "cycquery-0.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "6b3f69898624c40f889d43efd3f22a77",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.12,>=3.9",
            "size": 45095,
            "upload_time": "2024-04-18T16:19:06",
            "upload_time_iso_8601": "2024-04-18T16:19:06.552284Z",
            "url": "https://files.pythonhosted.org/packages/f0/c7/b244ec3135b7d1e4fc1cd8485c2f97b86a6db1ef11d7576b8b7675ea1c2b/cycquery-0.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-18 16:19:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "VectorInstitute",
    "github_project": "cycquery",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cycquery"
}
        
Elapsed time: 0.24309s