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:
- Parses key/value pairs passed in from a command line.
- Uses the parsed input to instantiate a DremioFlightEndpoint object.
- Creates a connection to the Arrow Flight server endpoint.
- Runs the query that was passed in as part of the input from the command line.
- Prints the query results.
Prerequisites
Install Python 3
Download and install the Dremio Flight Python Client Library v1.0.0 from the
Command for downloading and installingarrow-flight-client-examplesrepository in GitHub: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.whlDownload the file
arrow-flight-client-examples/python/example.pyor 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 templatepython3 <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.pyfile.-hostor--hostname: (Required) Set todata.dremio.cloud.-portor--flightport: (Required) Set to443.-pator--token: (Required) The personal access token or OAuth2 token to use for authentication.-tlsor--tls: (Required) Enables encryption.-queryor--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.-spor--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.-engineor--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:
python3 example.py -host data.dremio.cloud -port 443 \
-pat '<token>' -tls \
-query 'SELECT * FROM Samples."samples.dremio.com"."NYC-taxi-trips" limit 10'