# ibis-gizmosql
An [Ibis](https://ibis-project.org) back-end for [GizmoSQL](https://gizmodata.com/gizmosql)
[<img src="https://img.shields.io/badge/GitHub-gizmodata%2Fibis--gizmosql-blue.svg?logo=Github">](https://github.com/gizmodata/ibis-gizmosql)
[<img src="https://img.shields.io/badge/GitHub-gizmodata%2Fgizmosql--public-blue.svg?logo=Github">](https://github.com/gizmodata/gizmosql-public)
[](https://github.com/gizmodata/ibis-gizmosql/actions/workflows/ci.yml)
[](https://pypi.org/project/ibis-gizmosql/)
[](https://badge.fury.io/py/ibis-gizmosql)
[](https://pypi.org/project/ibis-gizmosql/)
# Setup (to run locally)
## Install Python package
You can install `ibis-gizmosql` from PyPi or from source.
### Option 1 - from PyPi
```shell
# Create the virtual environment
python3 -m venv .venv
# Activate the virtual environment
. .venv/bin/activate
pip install ibis-gizmosql
```
### Option 2 - from source - for development
```shell
git clone https://github.com/gizmodata/ibis-gizmosql
cd ibis-gizmosql
# Create the virtual environment
python3 -m venv .venv
# Activate the virtual environment
. .venv/bin/activate
# Upgrade pip, setuptools, and wheel
pip install --upgrade pip setuptools wheel
# Install the Ibis GizmoSQL back-end - in editable mode with client and dev dependencies
pip install --editable .[dev,test]
```
### Note
For the following commands - if you running from source and using `--editable` mode (for development purposes) - you will need to set the PYTHONPATH environment variable as follows:
```shell
export PYTHONPATH=$(pwd)/ibis_gizmosql
```
### Usage
In this example - we'll start a GizmoSQL server with the DuckDB back-end in Docker, and connect to it from Python using Ibis.
First - start the GizmoSQL server - which by default mounts a small TPC-H database:
```bash
docker run --name gizmosql \
--detach \
--rm \
--tty \
--init \
--publish 31337:31337 \
--env TLS_ENABLED="1" \
--env GIZMOSQL_PASSWORD="gizmosql_password" \
--env PRINT_QUERIES="1" \
--pull missing \
gizmodata/gizmosql:latest
```
Next - connect to the GizmoSQL server from Python using Ibis by running this Python code:
```python
import os
import ibis
from ibis import _
# Kwarg connection example
con = ibis.gizmosql.connect(host="localhost",
user=os.getenv("GIZMOSQL_USERNAME", "gizmosql_username"),
password=os.getenv("GIZMOSQL_PASSWORD", "gizmosql_password"),
port=31337,
use_encryption=True,
disable_certificate_verification=True
)
# URL connection example
# con = ibis.connect("gizmosql://gizmosql_username:gizmosql_password@localhost:31337?disableCertificateVerification=True&useEncryption=True")
print(con.tables)
# assign the LINEITEM table to variable t (an Ibis table object)
t = con.table('lineitem')
# use the Ibis dataframe API to run TPC-H query 1
results = (t.filter(_.l_shipdate.cast('date') <= ibis.date('1998-12-01') + ibis.interval(days=90))
.mutate(discount_price=_.l_extendedprice * (1 - _.l_discount))
.mutate(charge=_.discount_price * (1 + _.l_tax))
.group_by([_.l_returnflag,
_.l_linestatus
]
)
.aggregate(
sum_qty=_.l_quantity.sum(),
sum_base_price=_.l_extendedprice.sum(),
sum_disc_price=_.discount_price.sum(),
sum_charge=_.charge.sum(),
avg_qty=_.l_quantity.mean(),
avg_price=_.l_extendedprice.mean(),
avg_disc=_.l_discount.mean(),
count_order=_.count()
)
.order_by([_.l_returnflag,
_.l_linestatus
]
)
)
print(results.execute())
```
You should see output:
```text
l_returnflag l_linestatus sum_qty sum_base_price sum_disc_price sum_charge avg_qty avg_price avg_disc count_order
0 A F 380456.00 532348211.65 505822441.49 526165934.00 25.58 35785.71 0.05 14876
1 N F 8971.00 12384801.37 11798257.21 12282485.06 25.78 35588.51 0.05 348
2 N O 765251.00 1072862302.10 1019517788.99 1060424708.62 25.47 35703.76 0.05 30049
3 R F 381449.00 534594445.35 507996454.41 528524219.36 25.60 35874.01 0.05 14902
```
### Handy development commands
#### Version management
##### Bump the version of the application - (you must have installed from source with the [dev] extras)
```bash
bumpver update --patch
```
Raw data
{
"_id": null,
"home_page": null,
"name": "ibis-gizmosql",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "ibis, gizmosql, ibis-framework, flightsql, duckdb, adbc, gizmodata",
"author": null,
"author_email": "Philip Moore <philip@gizmodata.com>",
"download_url": "https://files.pythonhosted.org/packages/4b/d4/955cb591bade8ac5e436653831c7c2d6075de4096f47941284d968105e04/ibis_gizmosql-0.0.11.tar.gz",
"platform": null,
"description": "# ibis-gizmosql\nAn [Ibis](https://ibis-project.org) back-end for [GizmoSQL](https://gizmodata.com/gizmosql)\n\n[<img src=\"https://img.shields.io/badge/GitHub-gizmodata%2Fibis--gizmosql-blue.svg?logo=Github\">](https://github.com/gizmodata/ibis-gizmosql)\n[<img src=\"https://img.shields.io/badge/GitHub-gizmodata%2Fgizmosql--public-blue.svg?logo=Github\">](https://github.com/gizmodata/gizmosql-public)\n[](https://github.com/gizmodata/ibis-gizmosql/actions/workflows/ci.yml)\n[](https://pypi.org/project/ibis-gizmosql/)\n[](https://badge.fury.io/py/ibis-gizmosql)\n[](https://pypi.org/project/ibis-gizmosql/)\n\n# Setup (to run locally)\n\n## Install Python package\nYou can install `ibis-gizmosql` from PyPi or from source.\n\n### Option 1 - from PyPi\n```shell\n# Create the virtual environment\npython3 -m venv .venv\n\n# Activate the virtual environment\n. .venv/bin/activate\n\npip install ibis-gizmosql\n```\n\n### Option 2 - from source - for development\n```shell\ngit clone https://github.com/gizmodata/ibis-gizmosql\n\ncd ibis-gizmosql\n\n# Create the virtual environment\npython3 -m venv .venv\n\n# Activate the virtual environment\n. .venv/bin/activate\n\n# Upgrade pip, setuptools, and wheel\npip install --upgrade pip setuptools wheel\n\n# Install the Ibis GizmoSQL back-end - in editable mode with client and dev dependencies\npip install --editable .[dev,test]\n```\n\n### Note\nFor the following commands - if you running from source and using `--editable` mode (for development purposes) - you will need to set the PYTHONPATH environment variable as follows:\n```shell\nexport PYTHONPATH=$(pwd)/ibis_gizmosql\n```\n\n### Usage\nIn this example - we'll start a GizmoSQL server with the DuckDB back-end in Docker, and connect to it from Python using Ibis.\n\nFirst - start the GizmoSQL server - which by default mounts a small TPC-H database:\n\n```bash\ndocker run --name gizmosql \\\n --detach \\\n --rm \\\n --tty \\\n --init \\\n --publish 31337:31337 \\\n --env TLS_ENABLED=\"1\" \\\n --env GIZMOSQL_PASSWORD=\"gizmosql_password\" \\\n --env PRINT_QUERIES=\"1\" \\\n --pull missing \\\n gizmodata/gizmosql:latest\n```\n\nNext - connect to the GizmoSQL server from Python using Ibis by running this Python code:\n```python\nimport os\nimport ibis\nfrom ibis import _\n\n# Kwarg connection example\ncon = ibis.gizmosql.connect(host=\"localhost\",\n user=os.getenv(\"GIZMOSQL_USERNAME\", \"gizmosql_username\"),\n password=os.getenv(\"GIZMOSQL_PASSWORD\", \"gizmosql_password\"),\n port=31337,\n use_encryption=True,\n disable_certificate_verification=True\n )\n\n# URL connection example\n# con = ibis.connect(\"gizmosql://gizmosql_username:gizmosql_password@localhost:31337?disableCertificateVerification=True&useEncryption=True\")\n\nprint(con.tables)\n\n# assign the LINEITEM table to variable t (an Ibis table object)\nt = con.table('lineitem')\n\n# use the Ibis dataframe API to run TPC-H query 1\nresults = (t.filter(_.l_shipdate.cast('date') <= ibis.date('1998-12-01') + ibis.interval(days=90))\n .mutate(discount_price=_.l_extendedprice * (1 - _.l_discount))\n .mutate(charge=_.discount_price * (1 + _.l_tax))\n .group_by([_.l_returnflag,\n _.l_linestatus\n ]\n )\n .aggregate(\n sum_qty=_.l_quantity.sum(),\n sum_base_price=_.l_extendedprice.sum(),\n sum_disc_price=_.discount_price.sum(),\n sum_charge=_.charge.sum(),\n avg_qty=_.l_quantity.mean(),\n avg_price=_.l_extendedprice.mean(),\n avg_disc=_.l_discount.mean(),\n count_order=_.count()\n )\n .order_by([_.l_returnflag,\n _.l_linestatus\n ]\n )\n )\n\nprint(results.execute())\n```\n\nYou should see output:\n```text\n l_returnflag l_linestatus sum_qty sum_base_price sum_disc_price sum_charge avg_qty avg_price avg_disc count_order\n0 A F 380456.00 532348211.65 505822441.49 526165934.00 25.58 35785.71 0.05 14876\n1 N F 8971.00 12384801.37 11798257.21 12282485.06 25.78 35588.51 0.05 348\n2 N O 765251.00 1072862302.10 1019517788.99 1060424708.62 25.47 35703.76 0.05 30049\n3 R F 381449.00 534594445.35 507996454.41 528524219.36 25.60 35874.01 0.05 14902\n```\n\n### Handy development commands\n\n#### Version management\n\n##### Bump the version of the application - (you must have installed from source with the [dev] extras)\n```bash\nbumpver update --patch\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "An Ibis backend for GizmoSQL",
"version": "0.0.11",
"project_urls": {
"Homepage": "https://github.com/gizmodata/ibis-gizmosql"
},
"split_keywords": [
"ibis",
" gizmosql",
" ibis-framework",
" flightsql",
" duckdb",
" adbc",
" gizmodata"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "e9a3b7e16fb26389b2e87e5b95e90e0405e5c5323f1c58333917dcfdd8766bed",
"md5": "940a3513b5794417694b7145cf2bf685",
"sha256": "a263910d7c2e7835f55fbd66c6a31cc650f04236f9ac5c4615e369829c5268b8"
},
"downloads": -1,
"filename": "ibis_gizmosql-0.0.11-py3-none-any.whl",
"has_sig": false,
"md5_digest": "940a3513b5794417694b7145cf2bf685",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 20514,
"upload_time": "2025-11-05T19:43:04",
"upload_time_iso_8601": "2025-11-05T19:43:04.965909Z",
"url": "https://files.pythonhosted.org/packages/e9/a3/b7e16fb26389b2e87e5b95e90e0405e5c5323f1c58333917dcfdd8766bed/ibis_gizmosql-0.0.11-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "4bd4955cb591bade8ac5e436653831c7c2d6075de4096f47941284d968105e04",
"md5": "6dc3d9e96d3b4d5978366eed28caf15b",
"sha256": "49b591262415e44e0eb81588a86ed74e120c22684e35a2b456893de90df73854"
},
"downloads": -1,
"filename": "ibis_gizmosql-0.0.11.tar.gz",
"has_sig": false,
"md5_digest": "6dc3d9e96d3b4d5978366eed28caf15b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 22289,
"upload_time": "2025-11-05T19:43:06",
"upload_time_iso_8601": "2025-11-05T19:43:06.554466Z",
"url": "https://files.pythonhosted.org/packages/4b/d4/955cb591bade8ac5e436653831c7c2d6075de4096f47941284d968105e04/ibis_gizmosql-0.0.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-11-05 19:43:06",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "gizmodata",
"github_project": "ibis-gizmosql",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "ibis-gizmosql"
}