Query Firetiger with Python
ADBC is an API for interacting with databases using columnar data structures end-to-end. ADBC “drivers” implement the ADBC API for specific databases.
An official Python FlightSQL ADBC driver exists.
Generally speaking, it is configured with a URL such as jdbc:arrow-flight-sql://{host}:{port}
Install with a command like pip install adbc-driver-flightsql.
Usage
Create a FlightSQL client:
import adbc_driver_flightsql.dbapi
import adbc_driver_manager
host = 'query.<your firetiger deployment name>.firetigerapi.com'
port = 443
tls = True # False to disable TLS
username = '<find this on the Firetiger Integrations page>'
password = '<find this on the Firetiger Integrations page>'
scheme = 'grpc+tls' if tls else 'grpc'
uri = f"{scheme}://{host}:{port}"
conn = adbc_driver_flightsql.dbapi.connect(
uri,
db_kwargs={
adbc_driver_manager.DatabaseOptions.USERNAME.value: username,
adbc_driver_manager.DatabaseOptions.PASSWORD.value: password,
}
)
Now execute a query:
with conn.cursor() as cur:
cur.execute('SELECT COUNT(*) FROM logs')
table = cur.fetch_arrow_table()
The table object is a pyarrow.Table, which is a columnar data structure.
If you would rather work with a Pandas DataFrame, you can convert it with table.to_pandas():
df = table.to_pandas()
Clean up:
conn.close()