Fixing examples that still used datetime.datetime.utcnow() which almost always results in buggy code.
The issue is that utcnow() creates a local timezone object with the UTC time. In other words, as soon as that object is inserted into a database, its local timezone is converted to UTC and therefore skewed by N hours, unless the box's time just happens to be set to UTC.
In other words, to get the current timestamp use any of:
time.time_ns() or time.time() (former is nanos and an int).
TimestampNanos.now() when using the QuestDB API directly.
datetime.datetime.now(tz=utc) with timezone specified whenever you can.
datetime.datetime.now() for local time if you really really have to.
Fixing examples that still used
datetime.datetime.utcnow()
which almost always results in buggy code.The issue is that
utcnow()
creates a local timezone object with the UTC time. In other words, as soon as that object is inserted into a database, its local timezone is converted to UTC and therefore skewed by N hours, unless the box's time just happens to be set to UTC.In other words, to get the current timestamp use any of:
time.time_ns()
ortime.time()
(former is nanos and anint
).TimestampNanos.now()
when using the QuestDB API directly.datetime.datetime.now(tz=utc)
with timezone specified whenever you can.datetime.datetime.now()
for local time if you really really have to.Closes https://github.com/questdb/py-questdb-client/issues/37