ADBC Driver for Apache Arrow Flight SQL

1.11.0 · active · verified Thu Apr 16

adbc-driver-flightsql is a Python driver for connecting to databases via Apache Arrow Flight SQL. It provides both a low-level ADBC API and a DBAPI 2.0-compatible interface for efficient, Arrow-native data transfer. The library is actively maintained as part of the Apache Arrow ADBC project, with frequent releases, typically on a monthly or bi-monthly cadence. The current version is 1.11.0.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates connecting to an Apache Arrow Flight SQL server using the DBAPI 2.0 interface, executing a simple query, and fetching results as an Arrow Table. Connection details and authentication are typically passed via the URI and `db_kwargs` parameter, using environment variables for sensitive information.

import os
from adbc_driver_flightsql.dbapi import connect

# Replace with your Flight SQL server URI and authentication details
FLIGHT_SQL_URI = os.environ.get('ADBC_FLIGHT_SQL_URI', 'grpc+tls://localhost:50050')
FLIGHT_SQL_USERNAME = os.environ.get('ADBC_FLIGHT_SQL_USERNAME', '')
FLIGHT_SQL_PASSWORD = os.environ.get('ADBC_FLIGHT_SQL_PASSWORD', '')

db_options = {}
if FLIGHT_SQL_USERNAME and FLIGHT_SQL_PASSWORD:
    db_options['username'] = FLIGHT_SQL_USERNAME
    db_options['password'] = FLIGHT_SQL_PASSWORD

try:
    with connect(FLIGHT_SQL_URI, db_kwargs=db_options) as conn:
        with conn.cursor() as cursor:
            cursor.execute('SELECT 1 as example_column')
            result = cursor.fetch_arrow_table()
            print('Query successful!')
            print(result.to_pandas())
except Exception as e:
    print(f"Error connecting or querying: {e}")
    print("Please ensure your Flight SQL server is running and accessible,")
    print("and ADBC_FLIGHT_SQL_URI, USERNAME, and PASSWORD are correctly set if required.")

view raw JSON →