Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

Connecting Python and Sail with ADBC

Instructions

This example uses Sail, a fast query engine that supports Arrow Flight SQL.

Tip

If you already have a Sail Flight SQL server running, skip the steps to set up Sail.

Prerequisites

  1. Install uv

  2. Install dbc

Set up Sail

  1. Install Sail:

    uv tool install pysail
  2. Start the Sail Flight SQL server:

    sail flight server --ip 127.0.0.1 --port 32010

    Alternatively, you can start the server programmatically using the Sail Python API. Install pysail into your environment:

    uv pip install pysail

    Then start the server:

    from pysail.flight import FlightSqlServer
    
    server = FlightSqlServer(ip="127.0.0.1", port=32010)
    server.start(background=False)

Connect to Sail

  1. Install the Flight SQL ADBC driver:

    dbc install flightsql
  2. Customize the Python script main.py as needed

    • Change the connection arguments in db_kwargs
      • uri is the URI of your Sail Flight SQL server. The host and port will depend on your installation (the default port is 32010). The protocol scheme should be grpc for plain connections or grpc+tls if your server is configured with TLS.
    • Change the SQL SELECT statement in cursor.execute() if desired
  3. Run the Python script:

    uv run main.py

    The output will look something like this:

    pyarrow.Table
    result: int64
    ----
    result: [[2]]
    

Clean up

Stop the Sail Flight SQL server by pressing Ctrl-C in the terminal where it is running.