def _resolve_type(self, t, **kw):
"""
Resolve types for String, Numeric, Date/Time, etc. columns
"""
t = self.normalize_name(t)
if t in ischema_names:
#print(t,ischema_names[t])
t = ischema_names[t]
if issubclass(t, sqltypes.String):
return t(length=kw['length']/2 if kw['chartype']=='UNICODE' else kw['length'],\
charset=kw['chartype'])
elif issubclass(t, sqltypes.Numeric):
return t(precision=kw['prec'], scale=kw['scale'])
elif issubclass(t, sqltypes.Time) or issubclass(t, sqltypes.DateTime):
#Timezone
tz=kw['fmt'][-1]=='Z'
#Precision
prec = kw['fmt']
#For some timestamps and dates, there is no precision, or indicatd in scale
prec = prec[prec.index('(') + 1: prec.index(')')] if '(' in prec else 0
prec = kw['scale'] if prec=='F' else int(prec)
#prec = int(prec[prec.index('(') + 1: prec.index(')')]) if '(' in prec else 0
return t(precision=prec,timezone=tz)
elif issubclass(t, sqltypes.Interval):
return t(day_precision=kw['prec'],second_precision=kw['scale'])
else:
return t() # For types like Integer, ByteInt
return ischema_names[None]
评论列表
文章目录