https://questdb.io logo
Title
j

Jan W

05/24/2023, 8:01 PM
Hey, I hope you are well 🙂 I am trying to create a chart manually by using the SQL console
CREATE TABLE Warsaw_weather (temp float, clouds int, wind float, humidity int, pressure int, weather_id int, sunrise timestamp, sunset timestamp, timestamp timestamp)
next I am trying to write some data like so:
with Sender('localhost', 9009) as sender:
                sender.row(
                    (city+"_weather"),

                        columns = {
                    'temp' : float(row[0]),
                    'clouds' : int(row[1]),
                    'wind' : float(row[2]),
                    'humidity' : int(row[3]),
                    'pressure' : int(row[4]),
                    'weather_id' : int(row[5]),
                    'sunrise' : pd.to_datetime(row[6]).timestamp(),
                    'sunset' : pd.to_datetime(row[7]).timestamp(),
                    'timestamp': datetime.datetime.now().timestamp() * 1000000  # Current timestamp in nanoseconds
                    },
                # at=time_waw
                )

                sender.flush()
I am sure that the code attempts to write to the correct table however no data is added. also there are no errors and the code runs as expected. When I run the code without creating the table before a table is automatically created but it has floats instead of ints. I would appreciate any help with this issue. Thanks!
j

Jaromir Hamala

05/24/2023, 8:16 PM
hi Jan, is there any error on the server site? how are you checking the row is not inserted? by looking manually via the webconsole or programmatically?
j

Jan W

05/24/2023, 8:18 PM
no the program runs as expected, yes I am looking in the webconsole. I have this to catch errors and there aren't any...
except Exception as e:
        print(f'error, retrying in {INTERVAL}s\n {e}')
it seems like Quest writes data only if using the default datatypes created by default on the first write
i tried to work around it using casting but it didin't work
I have narrowed down that the issue is related to my timestamps
OK I GOT IT
'sunrise' : <http://pd.to|pd.to>_datetime(row[6] * 1000000000),
a

Andrey Pechkurov

05/25/2023, 6:47 AM
Hi Jan, We expect timestamps as ints (
i
suffix) or with
t
suffix. The granularity is microseconds. https://questdb.io/docs/reference/api/ilp/columnset-types/#timestamp