bugfix
This commit is contained in:
parent
63a4e89a7e
commit
854aaf6621
@ -37,7 +37,7 @@ drop table if exists {{summary[0].name}};
|
||||
CREATE TABLE {{summary[0].name}}
|
||||
(
|
||||
{% for field in fields %}
|
||||
{{field.name}} {{typeStr(field.type,field.length,field.dec)}} {{nullStr(field.nullable)}} {%if field.title -%} comment '{{field.title}}'{%- endif %}{%- if not loop.last -%},{%- endif -%}
|
||||
`{{field.name}}` {{typeStr(field.type,field.length,field.dec)}} {{nullStr(field.nullable)}} {%if field.title -%} comment '{{field.title}}'{%- endif %}{%- if not loop.last -%},{%- endif -%}
|
||||
{% endfor %}
|
||||
{% if summary[0].primary and len(summary[0].primary)>0 %}
|
||||
{{primary()}}
|
||||
|
10
sqlor/sor.py
10
sqlor/sor.py
@ -1,5 +1,6 @@
|
||||
from traceback import print_exc
|
||||
import os
|
||||
import decimal
|
||||
from asyncio import coroutine
|
||||
os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.UTF8'
|
||||
import sys
|
||||
@ -14,6 +15,11 @@ from appPublic.objectAction import ObjectAction
|
||||
from appPublic.argsConvert import ArgsConvert,ConditionConvert
|
||||
from .filter import DBFilter
|
||||
|
||||
def db_type_2_py_type(o):
|
||||
if isinstance(o,decimal.Decimal):
|
||||
return float(o)
|
||||
return o
|
||||
|
||||
class SQLorException(Exception,object):
|
||||
def __int__(self,**kvs):
|
||||
supper(SQLException,self).__init__(self,**kvs)
|
||||
@ -273,7 +279,7 @@ class SQLor(object):
|
||||
while rec is not None:
|
||||
dic = {}
|
||||
for i in range(len(fields)):
|
||||
dic.update({fields[i]:rec[i]})
|
||||
dic.update({fields[i] : db_type_2_py_type(rec[i])})
|
||||
callback(DictObject(**dic),**kwargs)
|
||||
if self.async_mode:
|
||||
rec = await cur.fetchone()
|
||||
@ -511,9 +517,7 @@ class SQLor(object):
|
||||
return desc
|
||||
desc = {}
|
||||
summary = [ i for i in await self.tables() if tablename.lower() == i.name ]
|
||||
print('summary=',summary)
|
||||
pris = await self.primary(tablename)
|
||||
print('primary key=',pris)
|
||||
primary = [i.name for i in pris ]
|
||||
summary[0]['primary'] = primary
|
||||
desc['summary'] = summary
|
||||
|
Loading…
Reference in New Issue
Block a user