Title
#users-public
m

Michal Zeman

09/13/2022, 8:35 AM
Hi guys, we would like to write and read binary data to/from QuestDB. We are using Python direct writer and/or WebUI. I was unable to write binary data with Python or WebUI. Is there a way to do it in WebUI? Thanks
Andrey Pechkurov

Andrey Pechkurov

09/13/2022, 8:48 AM
Hi Michal, You should be able to write and read binary values via PG Wire (so, a Postgres driver, like psycopg).
m

Michal Zeman

09/13/2022, 9:19 AM
Hi Andrey, do you have an example of the usage of this driver? Tbh I don't get how a driver can help me if it is not more of a protocol than a driver.
9:24 AM
As for the protocol vs. driver, Postgres driver uses PG Wire protocol and we support binary data reads and writes over PG Wire protocol.
m

Michal Zeman

09/13/2022, 9:43 AM
Thanks for the clarification. But with psycopg2 I have run to the same problem as here: https://github.com/questdb/questdb/issues/1187
Andrey Pechkurov

Andrey Pechkurov

09/13/2022, 10:31 AM
It seems to work fine with psycopg 3 for me:
import psycopg

with psycopg.connect("dbname=qdb user=admin password=quest host=localhost port=8812") as conn:

    with conn.cursor() as cur:

        cur.execute("CREATE TABLE IF NOT EXISTS binary_table (name STRING, binary_data BINARY);")
        cur.execute("INSERT INTO binary_table VALUES (%s,%s)", ('Hello', b'b string'))
        conn.commit()

        for record in cur.execute("SELECT * FROM binary_table"):
            print(record)
10:33 AM
Duplicated the snippet on the GH issue
m

Michal Zeman

09/13/2022, 11:31 AM
will try, thanks
2:44 PM
yeap in psycopg 3 it is working. but WebUI does not show anything and neither does downloading data via WebUI. But we can live with that. Thanks, Andrei 🙂
Andrey Pechkurov

Andrey Pechkurov

09/13/2022, 2:52 PM
Yes, if I'm not mistaken, HTTP API doesn't support binary columns. If you think it would be valuable for your needs, please create a GH issue to track this enhancement:https://github.com/questdb/questdb/issues/new?assignees=&labels=New+feature&template=feature_request.yml