Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/mysql/connector/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,25 @@ def _nonetype_to_mysql(self, value):
"""
return None

def _pendulum_to_mysql(self, value):
"""
pendulum just perform the same as datetime
add this to support python type pendulum
related issue to https://github.com/apache/airflow/issues/10795
"""
if value.microsecond:
fmt = '{0:04d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}.{6:06d}'
return fmt.format(
value.year, value.month, value.day,
value.hour, value.minute, value.second,
value.microsecond).encode('ascii')

fmt = '{0:04d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}'
return fmt.format(
value.year, value.month, value.day,
value.hour, value.minute, value.second).encode('ascii')


def _datetime_to_mysql(self, value):
"""
Converts a datetime instance to a string suitable for MySQL.
Expand Down