Skip to main content

Connect to Databend Using Python

Databend offers the following Python packages enabling you to develop Python applications that interact with Databend:

  • databend-driver (Recommended): A Python driver for Databend, providing both synchronous and asynchronous interfaces to interact with Databend, execute SQL queries, and handle data operations.
  • databend-sqlalchemy: Provides a SQL toolkit and Object-Relational Mapping to interface with the Databend database. SQLAlchemy is a popular SQL toolkit and ORM for Python, and databend-SQLAlchemy is a dialect for SQLAlchemy that allows you to use SQLAlchemy to interact with Databend.

Both packages require Python version 3.7 or higher. To check your Python version, run python --version in your command prompt. To install the latest databend-driver or databend-sqlalchemy package:

# install databend-driver
pip install databend-driver

# install databend-sqlalchemy
pip install databend-sqlalchemy

Data Type Mappings

This table illustrates the correspondence between Databend general data types and their corresponding Python equivalents:

DatabendPython
BOOLEANbool
TINYINTint
SMALLINTint
INTint
BIGINTint
FLOATfloat
DOUBLEfloat
DECIMALdecimal.Decimal
DATEdatetime.date
TIMESTAMPdatetime.datetime
VARCHARstr
BINARYbytes

This table illustrates the correspondence between Databend semi-structured data types and their corresponding Python equivalents:

DatabendPython
ARRAYlist
TUPLEtuple
MAPdict
VARIANTstr
BITMAPstr
GEOMETRYstr

Tutorials

Explore Databend Cloud for FREE
Low-cost
Fast Analytics
Easy Data Ingestion
Elastic Scaling
Try it today