Skip to main content

Python

You can develop client applications in Python that use that use Arrow Flight and connect to Dremio Cloud's Arrow Flight server endpoint.

For help getting started, try out the sample client application.

Running the Sample Python Client Application

This application performs these steps:

  1. Parses key/value pairs passed in from a command line.
  2. Uses the parsed input to instantiate a DremioFlightEndpoint object.
  3. Creates a connection to the Arrow Flight server endpoint.
  4. Runs the query that was passed in as part of the input from the command line.
  5. Prints the query results.

Prerequisites

  1. Install Python 3

  2. Download and install the Dremio Flight Python Client Library v1.0.0 from the arrow-flight-client-examples repository in GitHub:

    Command for downloading and installing
    python -m pip install https://github.com/dremio-hub/arrow-flight-client-examples/releases/download/dremio-flight-python-v1.0.0/dremio_flight-1.0.0-py3-none-any.whl
  3. Download the file arrow-flight-client-examples/python/example.py or copy its content into your own python file. The file is online here.

Supported Authentication Method

Use a personal access token.

Connecting to Dremio Cloud

Run the following command:

Command template
python3 <filename>.py -host data.dremio.cloud -port 443 \
-pat '<token>' -tls \
-query '<query>' \
[-sp <session-properties>] \
[-engine '<engine>']
  • <filename>: The path and name of the .py file.
  • -host or --hostname: (Required) Set to data.dremio.cloud.
  • -port or --flightport: (Required) Set to 443.
  • -pat or --token: (Required) The personal access token or OAuth2 token to use for authentication.
  • -tls or --tls: (Required) Enables encryption.
  • -query or --sqlQuery: (Required) The SQL command to run. Must be enclosed in single quotation marks. If single quotation marks are present within the query, change them to double quotation marks and enclose entire query in single quotation marks. See SQL commands for supported SQL commands.
  • -sp or --sessionProperty: (Optional) Additional properties that you can use to set the schema for a session and to manage query workloads. See Workload Management for the properties.
  • -engine or --engine: (Optional) The engine to use for running queries during the current session.

Example

To query the sample dataset NYC-taxi-trips and return the first 10 values, run this command:

Example of running a query
python3 example.py -host data.dremio.cloud -port 443 \
-pat '<token>' -tls \
-query 'SELECT * FROM Samples."samples.dremio.com"."NYC-taxi-trips" limit 10'