Skip to content

Commit

Permalink
UUID type hint (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
naturalethic authored Oct 29, 2021
1 parent 509cefe commit 989e046
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions aurora_data_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""
aurora-data-api - A Python DB-API 2.0 client for the AWS Aurora Serverless Data API
"""
import os, datetime, ipaddress, uuid, time, random, string, logging, itertools, reprlib
import os, datetime, ipaddress, time, random, string, logging, itertools, reprlib
from uuid import UUID
from decimal import Decimal
from collections import namedtuple
from .exceptions import (Warning, Error, InterfaceError, DatabaseError, DataError, OperationalError, IntegrityError,
Expand Down Expand Up @@ -116,7 +117,7 @@ class AuroraDataAPICursor:
"text": str,
"time": datetime.time,
"timestamp": datetime.datetime,
"uuid": uuid.uuid4,
"uuid": UUID,
"numeric": Decimal,
"decimal": Decimal
}
Expand All @@ -133,7 +134,8 @@ class AuroraDataAPICursor:
datetime.date: "DATE",
datetime.time: "TIME",
datetime.datetime: "TIMESTAMP",
Decimal: "DECIMAL"
Decimal: "DECIMAL",
UUID: "UUID"
}

def __init__(self, client=None, dbname=None, aurora_cluster_arn=None, secret_arn=None, transaction_id=None):
Expand Down Expand Up @@ -281,6 +283,8 @@ def _render_value(self, value, col_desc=None):
if col_desc and col_desc.type_code in self._data_api_type_hint_map:
if col_desc.type_code == Decimal:
scalar_value = Decimal(scalar_value)
elif col_desc.type_code == UUID:
scalar_value = UUID(scalar_value)
else:
try:
scalar_value = col_desc.type_code.fromisoformat(scalar_value)
Expand Down

0 comments on commit 989e046

Please sign in to comment.