Before you start
You need:- A running Query Engine cluster. On CloudPrem, the cluster also needs ingress. See Configure cluster ingress.
- A personal access token. See Create, rotate and revoke tokens.
- Python 3, with a C++ compiler. On Windows, install Visual C++ Build Tools first (see Windows setup below).
1
Install the connector
Install the package from PyPI.On Amazon Linux, CentOS, Ubuntu or Debian, install the build dependencies first if the install fails:
terminal
2
Set your credentials
Set the cluster host, your e6data email and your access token as environment variables. Do not hardcode them in your script.
terminal
3
Connect and run a query
Open a connection to the cluster, create a cursor on your catalog, and run SQL.
query.py
4
Close the connection
Clear and close the cursor, then close the connection. This frees old results from memory.
query.py
Windows setup
The connector uses a C-based deserialization library (fastbinary). On Windows it works only when Visual C++ Build Tools are installed. Without them you see this error:
- Install Visual C++ Build Tools and select the Desktop Development with C++ workload. Launch the Build Tools once after installing.
- Create and activate a virtual environment:
- Install the connector in that environment:
require_fastbinary=False to Connection. The connector then uses a pure-Python deserializer, which is about 2 to 3 times slower but otherwise works the same.
Related
Python connector reference
Reference · Connection parameters and the cursor API.
REST API for SQL queries
How-to · A driverless alternative over HTTPS.
Personal access tokens
Platform · Tokens the connector signs in with.