Python

Installation

The python-thingsdb library requires Python 3.6 or higher.

Just use pip:

pip install python-thingsdb

Or, clone the project and use setup.py:

python setup.py install

Quick usage

import asyncio
from thingsdb.client import Client


async def hello_world():
    client = Client()

    # replace `localhost` with your ThingsDB server address
    await client.connect('localhost')

    try:
        # replace `admin` and `pass` with your username and password
        # or use a valid token string
        await client.authenticate('admin', 'pass')

        # perform the hello world code...
        # the //ti comment is optional to tell your IDE to use ThingsDB
        # syntax highlighting if supported.
        print(await client.query("""//ti
            "Hello World!";
        """))

    finally:
        # the will close the client in a nice way
        client.close()
        await client.wait_closed()

# run the hello world example
asyncio.run(hello_world())

More info

A more complete description of the Python client can be found in one of the links below.