Skip to main content

ADBC: Arrow Database Connectivity

ADBC is a set of APIs and libraries for Arrow-native access to databases.

Spice supports ADBC clients using the FlightSQL driver.

Quickstart​

Get started with ADBC using Python.

Installation​

Start Python Envionment.

python

Install the ADBC driver manager, FlightSQL driver, and PyArrow.

pip install adbc_driver_manager adbc_driver_flightsql pyarrow

Create a connection to Spice over ADBC​

>>> import adbc_driver_flightsql.dbapi
>>> conn = adbc_driver_flightsql.dbapi.connect('grpc://localhost:50051')

Create a cursor​

>>> cursor = conn.cursor()

Executing a query​

DBAPI interface:

>>> cursor.execute("SELECT 1, 2.0, 'Hello, world!'")
>>> cursor.fetchone()
(1, 2.0, 'Hello, world!')
>>> cursor.execute("SHOW TABLES")
>>> cursor.fetchall()
[('spice', 'public', 'messages', 'BASE TABLE'), ('spice', 'runtime', 'query_history', 'BASE TABLE'), ('spice', 'information_schema', 'tables', 'VIEW'), ('spice', 'information_schema', 'views', 'VIEW'), ('spice', 'information_schema', 'columns', 'VIEW'), ('spice', 'information_schema', 'df_settings', 'VIEW'), ('spice', 'information_schema', 'schemata', 'VIEW')]

Arrow:

>>> cursor.execute("SELECT 1, 2.0, 'Hello, world!'")
>>> cursor.fetch_arrow_table()
pyarrow.Table
1: int64
2.0: double
'Hello, world!': string
----
1: [[1]]
2.0: [[2]]
'Hello, world!': [["Hello, world!"]]