Skip to main content
Version: 0.0.1

Python

You can develop client applications in Python that use that use Arrow Flight and connect to Dremio'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: {{< codeheader "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 Methods

  • Use a username and password for an account in your Dremio instance.

Connecting to Dremio

Run the following command: {{< codeheader "Command template" >}}

python3 <filename>.py -host data.dremio.cloud -port 443 \
-user <username> -pass `<password>` -tls \
-query '<query>' \
[-dcv DISABLE_CERTIFICATE_VERIFICATION] \
[-path_to_certs PATH_TO_CERTS] \
[-sp <session-properties>]
  • <filename>: The path and name of the .py file.
  • -host or --hostname: (Optional) The hostname for the coordinator node in a Dremio cluster. Defaults to localhost.
  • -port or --flightport: (Optional) The port for the Arrow Flight server endpoint. Defaults to 32010.
  • -user or --username: (Required) The username of the account to use for authentication.
  • -pass or --password: (Required) The password or personal access token to use for authentication.
  • -tls or --tls: (Optional) Enables encryption. Disabled by default.
  • -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.
  • -dcv DISABLE_CERTIFICATE_VERIFICATION or --disableCertificateVerification DISABLE_CERTIFICATE_VERIFICATION: (Optional) Disables TLS server verification. Enabled by default.
  • -path_to_certs PATH_TO_CERTS or --trustedCertificates PATH_TO_CERTS: (Optional) The path to trusted certificates for encrypted connections. Defaults to system certificates.
  • -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.

Example

To query the sample dataset NYC-taxi-trips and return the first 10 values, run this command, which connects to Dremio running on localhost:

{{< codeheader "Example of running a query" >}}

python3 example.py -user user1 -pass myPassword \
-query 'SELECT * FROM Samples."samples.dremio.com"."NYC-taxi-trips" limit 10'