Skip to content

About

No description, website, or topics provided.

Resources

Code of conduct

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

greptimedb-ingester

中文

Synchronous Python write client for GreptimeDB. Python 3.10+.

Install

uv add "greptimedb-ingester[postgres]"       # PostgreSQL COPY
uv add "greptimedb-ingester[grpc]"           # gRPC
uv add "greptimedb-ingester[grpc,postgres]"  # Both

Or use pip install with the same requirements. In requirements.txt, omit quotes. Choose at least one backend. [postgres] uses psycopg2 without the Rust SDK.

PostgreSQL COPY

from greptimedb_ingester import Column, ColumnDataType as D, SemanticType as S
from greptimedb_ingester.postgres import Client

columns = [
    Column("host", D.STRING, S.TAG),
    Column("ts", D.TIMESTAMP_MILLISECOND, S.TIMESTAMP),
    Column("reading", D.FLOAT64, S.FIELD),
]
with Client(["127.0.0.1:4003"], batch_size=5000) as client:
    affected = client.insert("sensor_data", columns, [
        ["edge", 1793066400000, 23.5],
    ])
print(affected)

insert creates missing tables and writes COPY batches (default: 10,000 rows). Batches commit separately. The server must support COPY FROM STDIN. See the API reference for supported types and timestamp rules.

gRPC

from greptimedb_ingester.grpc import Client

client = Client(["127.0.0.1:4001"], database="public")
# client.insert(table, columns, rows)

Supports insert, delete, and bulk_writer. See usage and examples. With both backends installed, the root Client defaults to gRPC; use the explicit imports above to select a backend.

Development

uv sync --python 3.10 --locked --extra postgres
uv run --extra postgres pytest

For both backends, use --all-extras instead of --extra postgres (requires Rust 1.85+). See testing and release for integration tests and publishing.

About

No description, website, or topics provided.

Resources

Code of conduct

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages