sqlor/dataloader/typeconv.py

26 lines
441 B
Python
Raw Normal View History

2024-09-23 14:19:50 +08:00
convfuncs = {
'int':int,
'long':int,
'llong':int,
'float':float,
'double':float,
'date':str,
'datetime':str,
'ddouble':float
}
def conv(info, name, value):
fields = info['fields']
for f in fields:
if f['name'] == name:
f = convfuncs.get(f['type'], None)
if f is None or value is None:
return value
return f(value)
return value
def convrec(info, ns):
ret = {k:conv(info, k, v) for k,v in ns.items()}
return ret