crate-python icon indicating copy to clipboard operation
crate-python copied to clipboard

Inserting aware Datetime returns an error.

Open MarkRatFelt opened this issue 5 years ago • 2 comments

I'm trying to insert some DateTime data to CrateDB, but I'm getting an error.

The datetime I'm trying to insert looks so:

Screen Shot 2020-07-16 at 16 25 41

The column is a Timestamp with time zone column.

But I get this error:

  File "/Users/chuckaguilar/PycharmProjects/postgres-cratedb-migration-tool/venv/lib/python3.7/site-packages/crate/client/http.py", line 82, in default
    delta = o - self.epoch
TypeError: can't subtract offset-naive and offset-aware datetimes

But the CrateJsonEncoder (self.epoch) is naive:

Screen Shot 2020-07-16 at 16 28 44

tzinfo is None

So... it won't work. Either I make my datetime naive, or the self.epoch gotta be aware.

MarkRatFelt avatar Jul 16 '20 14:07 MarkRatFelt

It'd work converting it to a string via datetime.strftime("%Y-%m-%dT%H:%M:%S.%f%z")

thanks, @autophagy :)

MarkRatFelt avatar Jul 16 '20 14:07 MarkRatFelt

Related to #359

chaudum avatar Sep 10 '20 11:09 chaudum