You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.............
File "/anaconda3/envs/study/lib/python3.6/site-packages/clickhouse_driver/columns/service.py", line 80, in write_column
column.write_data(items, buf)
File "/anaconda3/envs/study/lib/python3.6/site-packages/clickhouse_driver/columns/base.py", line 79, in write_data
self._write_data(items, buf)
File "/anaconda3/envs/study/lib/python3.6/site-packages/clickhouse_driver/columns/base.py", line 82, in _write_data
prepared = self.prepare_items(items)
File "/anaconda3/envs/study/lib/python3.6/site-packages/clickhouse_driver/columns/base.py", line 69, in prepare_items
x = before_write(x)
File "/anaconda3/envs/study/lib/python3.6/site-packages/clickhouse_driver/columns/datetimecolumn.py", line 26, in before_write_item
if value.tzinfo is None:
AttributeError: 'NoneType' object has no attribute 'tzinfo'
def before_write_item(self, value):
if self.timezone:
# Set server's timezone for offset-naive datetime.
# if value.tzinfo is None:
# value = self.timezone.localize(value)
# value = value.astimezone(utc)
# return int(timegm(value.timetuple()))
"""
my code
"""
if hasattr(value, 'tzinfo'):
if value.tzinfo is None:
value = self.timezone.localize(value)
value = value.astimezone(utc)
return int(timegm(value.timetuple()))
else:
return 0
else:
# If datetime is offset-aware use it's timezone.
if value.tzinfo is not None:
value = value.astimezone(utc)
return int(timegm(value.timetuple()))
return int(mktime(value.timetuple()))
Null date can also be inserted into Clickhouse (0000-00-00 00:00:00).
The text was updated successfully, but these errors were encountered:
If I use pandas.dataframe.to_sql, insert the empty date value in dataframe to Clickhouse,There will be a mistake here.
code
error message
so,I edit 'clickhouse_driver/columns/datetimecolumn.py',such as:
Null date can also be inserted into Clickhouse (0000-00-00 00:00:00).
The text was updated successfully, but these errors were encountered: