Skip to main content

Timeplus python SDK

Project description

Timeplus API Python SDK

Timeplus Python SDK

to install the sdk, run pip install timeplus

from rx import operators as ops
from timeplus import Stream, StreamColumn, Query, Env

# initialize timeplus environment
api_key = os.environ.get("TIMEPLUS_API_KEY")
env = (
    Env().schema("https").host("hostname").port("443").api_key(api_key)
)
Env.setCurrent(env)

# create a stream
s = (
    Stream()
    .name("stream_name")
    .column(StreamColumn().name("field_name_a").type("string"))
    .column(StreamColumn().name("field_name_b").type("float64"))
)

s.create()

# insert data into stream
s.insert(
    [
        [
            "hello",
            100.1
        ],
        [
            "timeplus",
            20.2
        ],
    ]
)

# delete stream
s.delete()

# run query on existing stream
query = Query().sql(f"select * from stream_name")
query.create()

query.get_result_stream().pipe(ops.take(5)).subscribe(
    on_next=lambda i: print(f"get one query result {i}"),
    on_error=lambda e: print(f"error {e}"),
    on_completed=lambda: query.stop(),
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

timeplus-0.1.9.tar.gz (282.3 kB view hashes)

Uploaded Source

Built Distribution

timeplus-0.1.9-py3-none-any.whl (14.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page