Skip to content

Commit

Permalink
vector type params
Browse files Browse the repository at this point in the history
  • Loading branch information
nakagami committed Aug 23, 2024
1 parent 18d5cb1 commit da2b948
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cymysql/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ def escape_decimal(obj):
return str(obj)


def escape_vector(obj):
import numpy as np
return escape_bytes(obj.astype(np.float32).tobytes())


def convert_datetime(obj):
"""Returns a DATETIME or TIMESTAMP column value as a datetime object:
Expand Down Expand Up @@ -355,6 +360,12 @@ def convert_decimal(obj):
encoders[unicode] = escape_string
encoders[long] = escape_long

try:
import numpy as np
encoders[np.ndarray] = escape_vector
except ImportError:
pass


def escape_item(val, charset, encoders=encoders):
if type(val) in [tuple, list, set]:
Expand Down

0 comments on commit da2b948

Please sign in to comment.