ClickZetta Python Connector

raw JSON →
0.8.109 verified Fri May 01 auth: no python

Official Python connector for ClickZetta cloud database. Version 0.8.109. Provides a DB-API 2.0 interface for querying and managing ClickZetta clusters. Regular releases.

pip install clickzetta-connector-python
error clickzetta.exceptions.ClickZettaError: 401 Unauthorized
cause Invalid username or password provided in connect().
fix
Double-check credentials; ensure user exists and password is correct. Use environment variables.
error websockets.exceptions.InvalidHandshake: Status 403
cause Server IP is not allowed or WebSocket subprotocol mismatch.
fix
Check firewall rules and ensure ClickZetta server allows WebSocket connections from your IP.
error AttributeError: module 'clickzetta' has no attribute 'connect'
cause Importing from 'clickzetta_connector' instead of 'clickzetta'.
fix
Use 'import clickzetta' or 'from clickzetta import connect'.
breaking In version 0.8.x, the WebSocket endpoint changed from '/sql' to '/ws'. Old clients using '/sql' will get connection errors.
fix Update the URL to use '/ws' (default: ws://host:port/ws).
deprecated The 'database' parameter in connect() is deprecated; use 'schema' instead.
fix Use conn.set_schema('schema_name') or include schema in SQL.
gotcha The connector uses WebSocket, not HTTP. Ensure your firewall allows WebSocket traffic on the configured port.
fix Use ws:// or wss:// URL and verify network connectivity.

Establishes a WebSocket connection to ClickZetta, executes a query, and prints the result.

import clickzetta
conn = clickzetta.connect(
    url=os.environ.get('CLICKZETTA_URL', 'ws://localhost:8080/ws'),
    user=os.environ.get('CLICKZETTA_USER', 'default'),
    password=os.environ.get('CLICKZETTA_PASSWORD', ''),
    database='default'
)
cursor = conn.cursor()
cursor.execute('SELECT version()')
print(cursor.fetchone())
cursor.close()
conn.close()