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:
- 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
arrow-flight-client-examplesrepository 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 - Download the file
arrow-flight-client-examples/python/example.pyor 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.
- Use a username and a personal access token.
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.pyfile.-hostor--hostname: (Optional) The hostname for the coordinator node in a Dremio cluster. Defaults tolocalhost.-portor--flightport: (Optional) The port for the Arrow Flight server endpoint. Defaults to32010.-useror--username: (Required) The username of the account to use for authentication.-passor--password: (Required) The password or personal access token to use for authentication.-tlsor--tls: (Optional) Enables encryption. Disabled by default.-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.-dcv DISABLE_CERTIFICATE_VERIFICATIONor--disableCertificateVerification DISABLE_CERTIFICATE_VERIFICATION: (Optional) Disables TLS server verification. Enabled by default.-path_to_certs PATH_TO_CERTSor--trustedCertificates PATH_TO_CERTS: (Optional) The path to trusted certificates for encrypted connections. Defaults to system certificates.-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.
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'