Skip to content

Latest commit

History

History
72 lines (53 loc) 路 2 KB

File metadata and controls

72 lines (53 loc) 路 2 KB

Python ADBC Client with Parameterized Queries

Works with v1.0+

This repository provides a simple cookbook example demonstrating how to use Python to query Spice via the Apache Arrow Database Connectivity (ADBC) API with the Flight SQL interface to Spice OSS. The example script connects to a local Spice OSS runtime, executes a parameterized query and a simple query, and fetches results as Arrow Tables.

Requirements

  • Python 3.8+
  • Spice CLI installed and Spice OSS runtime available
  • pip

Recipe Steps

1. Clone this repository

git clone https://github.com/spiceai/cookbook.git
cd cookbook/clients/adbc

2. Install dependencies

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

3. Start Spice OSS

In a separate terminal, start the Spice OSS runtime:

spice run

4. Execute the ADBC client script

In a new terminal within the cookbook/clients/adbc directory, re-activate the virtual environment and run the sample ADBC script:

source .venv/bin/activate
python3 main.py

Expected output:

pyarrow.Table
AccountId: string
ServiceId: string
AddOnSid: string
AddOnTypeSid: string
AddOnJson: string
DateCreated: timestamp[s]
DateUpdated: timestamp[s]
----
AccountId: [["account123","account789","account456"]]
ServiceId: [["service789","service789","service789"]]
AddOnSid: [["addon3","addon7","addon10"]]
AddOnTypeSid: [["type123","type123","type789"]]
AddOnJson: [["{\feature\":\"voice_integration\"}"","{\feature\":\"voice_integration\"}"","{\feature\":\"mms_support\"}""]]
DateCreated: [[2025-04-03 15:45:00,2025-04-07 11:30:00,2025-04-10 09:45:00]]
DateUpdated: [[2025-04-03 15:45:00,2025-04-07 11:30:00,2025-04-10 09:45:00]]

Learn more