mirror of
https://github.com/coleifer/peewee.git
synced 2026-05-06 07:56:41 -04:00
Add mapping of field type -> py type.
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import datetime
|
||||
import decimal
|
||||
import re
|
||||
import uuid
|
||||
import warnings
|
||||
from collections import OrderedDict
|
||||
from collections import namedtuple
|
||||
@@ -34,6 +37,32 @@ RESERVED_WORDS = set([
|
||||
])
|
||||
|
||||
|
||||
FieldTypeMap = {
|
||||
'AUTO': int,
|
||||
'BIGAUTO': int,
|
||||
'BIGINT': int,
|
||||
'BLOB': bytes,
|
||||
'BOOL': bool,
|
||||
'CHAR': str,
|
||||
'DATE': datetime.date,
|
||||
'DATETIME': datetime.datetime,
|
||||
'DECIMAL': decimal.Decimal,
|
||||
'DOUBLE': float,
|
||||
'FLOAT': float,
|
||||
'INT': int,
|
||||
'SMALLINT': int,
|
||||
'TEXT': str,
|
||||
'TIME': datetime.time,
|
||||
'UUID': uuid.UUID,
|
||||
'UUIDB': bytes,
|
||||
'VARCHAR': str,
|
||||
'JSON': dict,
|
||||
'JSONB': dict,
|
||||
'TIMESTAMPTZ': datetime.datetime,
|
||||
'INTERVAL': datetime.timedelta,
|
||||
}
|
||||
|
||||
|
||||
class UnknownField(object):
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user