PyDoris

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

PyDoris is a Python client for Apache Doris, providing a DB-API 2.0 compatible interface to interact with Doris databases. Current version is 1.2.0, supporting Python >=3.7. It connects via MySQL protocol (typically port 9030). The library is maintained by the Apache Doris community.

pip install pydoris
error pydoris.exceptions.DorisError: (HY000, 'Access denied for user ...')
cause Incorrect username or password, or user not allowed from the connecting host.
fix
Verify credentials and user host: CREATE USER 'user'@'%' IDENTIFIED BY 'password'; then GRANT.
error ModuleNotFoundError: No module named 'pydoris'
cause Package not installed or installed in wrong environment.
fix
Run pip install pydoris and ensure you are using the correct Python interpreter.
error pydoris.exceptions.DorisError: (2003, "Can't connect to MySQL server on '...' (timed out)")
cause Doris server not reachable, wrong port, or firewall blocking port 9030.
fix
Check Doris is running, port is correct (default 9030), and network/firewall rules allow access.
gotcha Port should be the MySQL protocol port (default 9030), not the HTTP port (8030). Common mistake caused by misreading Doris documentation.
fix Use port 9030 (or your configured query port).
gotcha PyDoris uses the MySQL protocol; ensure the Doris server has MySQL protocol enabled and the user has proper host permissions.
fix Check user host in Doris: `SHOW GRANTS;` and ensure `mysql_native_password` authentication.
deprecated The `pydoris` package on PyPI is version 1.2.0, which may be outdated compared to latest Doris releases. Many users mistakenly install an old version expecting latest features.
fix Check for updates; consider using official mysql-connector-python if needed.

Connect to Apache Doris, execute a query, and print the version.

import os
from pydoris import connect

host = os.environ.get('DORIS_HOST', 'localhost')
port = int(os.environ.get('DORIS_PORT', 9030))
user = os.environ.get('DORIS_USER', 'root')
password = os.environ.get('DORIS_PASSWORD', '')
database = os.environ.get('DORIS_DATABASE', 'test')

conn = connect(host=host, port=port, user=user, password=password)
cursor = conn.cursor()
cursor.execute("SELECT VERSION()")
print(cursor.fetchone())
cursor.close()
conn.close()