Skip to main content

drillpy is a Python wrapper for Apache Drill’s REST API, which lets you query and import data to Python directly from a working Drill cluster/drillbit instance. It is built on top on requests, numpy and pandas.

Installation

pip install drillpy

Usage

drillpy follows the Python Database API Specification v2.0, so it’s usage is pretty similar to the one you can find e.g. in the builtin sqlite3 module from CPython’s Standard Library.

As with sqlite3, you should start by creating a Connection object, using drillpy.connect():

from drillpy import connect

con = connect(host=”some_drillbit_host”, db=”some_database_managed_by_drill”, port=8047)

Once created, you must create a Cursor:

cur = con.cursor()

Now you can use this cursor to write SQL queries against your Drill cluster. Parameter substitution is handled by question marks ? (as in sqlite3):

query = cur.execute(“SELECT * FROM mytable WHERE somecolumn > ? AND someothercolumn < ? LIMIT 10”, (value, other_value))

Results are returned in a pandas DataFrame, with NaNs in missing values. Column types are inferred automatically. You can retreive results with fetchone(), fetchmany(size) and fetchall(). With fetchone(), a pandas Series is returned rather than a DataFrame:

returned_df = query.fetchall()

Keep in mind that drillpy cannot insert new data in your tables/databases, since Drill itself is a querying engine meant to be used for exploratory data analysis and BI/visualization tools.

Once finished, you should call Connection.close():

con.close()

Release files for drillpy 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for drillpy 0.2.0
File Interpreter ABI Platform
drillpy-0.2.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Release files / drillpy-0.2.0-py2.py3-none-any.whl

Download URL drillpy-0.2.0-py2.py3-none-any.whl
Size 5.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
2d4ebe932328f3a76dc339047630c172fc053796624b2d74742f16fe0137c8ff
BLAKE2b-256 checksum
How to use checksums
b9d1b510b337a618e359867eed731d3046ecd4fbc83f05ad09a3a3b19b30144e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page