Skip to main content

QuestDB Python Client

This is an open-source Python library for interacting with QuestDB, a high-performance, open-source SQL database designed to process time series data. This client provides an easy-to-use interface for querying and writing data to QuestDB from Python applications.

Features

  • Asynchronous and synchronous query execution
  • Write single or multiple messages to QuestDB
  • Buffer writes for improved performance
  • Convert query results to Pandas DataFrames
  • Type conversion and parsing of query results
  • Support for both HTTP and TCP interfaces

Installation

You can install the QuestDB Python Client using pip:

pip install py-questdb

Quick Start

Here's a simple example to get you started:

import asyncio
from questdb_python_client import QuestDB

async def main():
    # Connect to QuestDB
    db = QuestDB(host="localhost", port=9000)

    # Write some data
    await db.write(
        table_name="sensors",
        symbols={"location": "room1"},
        columns={"temperature": 22.5, "humidity": 60},
        at=datetime.now()
    )

    # Query data
    async for row in db.query("SELECT * FROM sensors ORDER BY timestamp DESC LIMIT 10"):
        print(row)

    # Query data as a DataFrame
    df = await db.query_df("SELECT * FROM sensors WHERE location = 'room1'")
    print(df)

    await db.close()

asyncio.run(main())

Usage

Connecting to QuestDB

from questdb_python_client import QuestDB

# For HTTP interface
db = QuestDB(host="localhost", port=9000)

# For TCP interface
db = QuestDB(host="localhost", port=9009)

Writing Data

# Write a single message
db.write(
    table_name="sensors",
    symbols={"location": "room1"},
    columns={"temperature": 22.5, "humidity": 60},
    at=datetime.now()
)

# Write multiple messages
messages = [
    QuestMessage(table_name="sensors", symbols={"location": "room1"}, columns={"temperature": 22.5}, at=datetime.now()),
    QuestMessage(table_name="sensors", symbols={"location": "room2"}, columns={"temperature": 23.1}, at=datetime.now())
]
db.write_iter(messages)

Querying Data

# Asynchronous query
async for row in db.query("SELECT * FROM sensors WHERE location = 'room1'"):
    print(row)

# Synchronous query
for row in db.query_sync("SELECT * FROM sensors WHERE location = 'room1'"):
    print(row)

# Query as DataFrame
df = await db.query_df("SELECT * FROM sensors WHERE location = 'room1'")
print(df)

License

This project is licensed under the MIT License.

Metadata

Release files for py-questdb 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-questdb 0.0.2
File Size Uploaded
py_questdb-0.0.2.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-questdb 0.0.2
File Interpreter ABI Platform
py_questdb-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.7 kB

Release files / py_questdb-0.0.2.tar.gz

Download URL py_questdb-0.0.2.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
02735f6bd74fea9b6aea8b3b36546ee44bb9a4a9bcd44f12176b4e5cc8a91b5e
BLAKE2b-256 checksum
How to use checksums
0dffeb4f676e3b1cd82c0ea0a35d50a546e26cabb8e965ebb4d10319bb230f08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.5

Release files / py_questdb-0.0.2-py3-none-any.whl

Download URL py_questdb-0.0.2-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e3e2357db8a37ad244a13494a790edb00ebd21d44c2d2d4ab1f6c7329b630873
BLAKE2b-256 checksum
How to use checksums
155b38d535ea55f6d29e32b4122def86d5c36f04f9748ea3f6f4aa2a2f37c5a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.5

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page