bugfix
This commit is contained in:
parent
321ea27da0
commit
cc9e37d644
@ -39,7 +39,9 @@ CREATE TABLE {{summary[0].name}}
|
|||||||
{% for field in fields %}
|
{% 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 %}
|
{% endfor %}
|
||||||
|
{% if summary[0].primary and len(summary[0].primary)>0 %}
|
||||||
{{primary()}}
|
{{primary()}}
|
||||||
|
{% endif %}
|
||||||
)
|
)
|
||||||
engine=innodb
|
engine=innodb
|
||||||
default charset=utf8
|
default charset=utf8
|
||||||
|
@ -33,7 +33,9 @@ CREATE TABLE {{summary[0].name}}
|
|||||||
{% for field in fields %}
|
{% for field in fields %}
|
||||||
{{field.name}} {{typeStr(field.type,field.length,field.dec)}} {{nullStr(field.nullable)}}{%- if not loop.last -%},{%- endif -%}
|
{{field.name}} {{typeStr(field.type,field.length,field.dec)}} {{nullStr(field.nullable)}}{%- if not loop.last -%},{%- endif -%}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% if summary[0].primary and len(summary[0].primary)>0 %}
|
||||||
{{primary()}}
|
{{primary()}}
|
||||||
|
{% endif %}
|
||||||
);
|
);
|
||||||
{% for v in indexes %}
|
{% for v in indexes %}
|
||||||
CREATE {% if v.idxtype=='unique' %}UNIQUE{% endif %} INDEX {{summary[0].name}}_{{v.name}} ON {{summary[0].name}}({{",".join(v.idxfields)}});
|
CREATE {% if v.idxtype=='unique' %}UNIQUE{% endif %} INDEX {{summary[0].name}}_{{v.name}} ON {{summary[0].name}}({{",".join(v.idxfields)}});
|
||||||
|
@ -29,9 +29,11 @@ DROP TABLE IF EXISTS {{summary[0].name}};
|
|||||||
CREATE TABLE {{summary[0].name}}
|
CREATE TABLE {{summary[0].name}}
|
||||||
(
|
(
|
||||||
{% for field in fields %}
|
{% for field in fields %}
|
||||||
{{field.name}} {{typeStr(field.type,field.length,field.dec)}} {{nullStr(field.nullable)}},
|
{{field.name}} {{typeStr(field.type,field.length,field.dec)}} {{nullStr(field.nullable)}}{%- if not loop.last -%},{%- endif -%}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% if summary[0].primary and len(summary[0].primary)>0 %}
|
||||||
{{primary()}}
|
{{primary()}}
|
||||||
|
{% endif %}
|
||||||
);
|
);
|
||||||
{% for v in indexes %}
|
{% for v in indexes %}
|
||||||
CREATE {% if v.idxtype=='unique' %}UNIQUE{% endif %} INDEX {{summary[0].name}}_{{v.name}} ON {{summary[0].name}}({{",".join(v.idxfields)}});
|
CREATE {% if v.idxtype=='unique' %}UNIQUE{% endif %} INDEX {{summary[0].name}}_{{v.name}} ON {{summary[0].name}}({{",".join(v.idxfields)}});
|
||||||
|
@ -35,7 +35,9 @@ CREATE TABLE dbo.{{summary[0].name}}
|
|||||||
{% for field in fields %}
|
{% for field in fields %}
|
||||||
{{field.name}} {{typeStr(field.type,field.length,field.dec)}} {{nullStr(field.nullable)}}{%- if not loop.last -%},{%- endif -%}
|
{{field.name}} {{typeStr(field.type,field.length,field.dec)}} {{nullStr(field.nullable)}}{%- if not loop.last -%},{%- endif -%}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% if summary[0].primary and len(summary[0].primary)>0 %}
|
||||||
{{primary()}}
|
{{primary()}}
|
||||||
|
{% endif %}
|
||||||
)
|
)
|
||||||
{% for v in indexes %}
|
{% for v in indexes %}
|
||||||
CREATE {% if v.idxtype=='unique' %}UNIQUE{% endif %} INDEX {{summary[0].name}}_{{v.name}} ON {{summary[0].name}}({{",".join(v.idxfields)}});
|
CREATE {% if v.idxtype=='unique' %}UNIQUE{% endif %} INDEX {{summary[0].name}}_{{v.name}} ON {{summary[0].name}}({{",".join(v.idxfields)}});
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from traceback import print_exc
|
||||||
import os
|
import os
|
||||||
from asyncio import coroutine
|
from asyncio import coroutine
|
||||||
os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.UTF8'
|
os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.UTF8'
|
||||||
@ -87,6 +88,8 @@ class SQLor(object):
|
|||||||
primary = await self.primary(t.name)
|
primary = await self.primary(t.name)
|
||||||
indexes = concat_idx_info(await self.indexes(t.name))
|
indexes = concat_idx_info(await self.indexes(t.name))
|
||||||
fields = await self.fields(t.name)
|
fields = await self.fields(t.name)
|
||||||
|
primary_fields = [f.field_name for f in primary]
|
||||||
|
if len(primary_fields)>0:
|
||||||
t.primary = [f.field_name for f in primary]
|
t.primary = [f.field_name for f in primary]
|
||||||
x = {}
|
x = {}
|
||||||
x['summary'] = [t]
|
x['summary'] = [t]
|
||||||
@ -201,7 +204,6 @@ class SQLor(object):
|
|||||||
markedSQL,datas = self.maskingSQL(sql,NS)
|
markedSQL,datas = self.maskingSQL(sql,NS)
|
||||||
datas = self.dataConvert(datas)
|
datas = self.dataConvert(datas)
|
||||||
try:
|
try:
|
||||||
# markedSQL = markedSQL.encode('utf8')
|
|
||||||
if self.async_mode:
|
if self.async_mode:
|
||||||
await cursor.execute(markedSQL,datas)
|
await cursor.execute(markedSQL,datas)
|
||||||
else:
|
else:
|
||||||
@ -209,6 +211,7 @@ class SQLor(object):
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print( "markedSQL=",markedSQL,':',datas,':',e)
|
print( "markedSQL=",markedSQL,':',datas,':',e)
|
||||||
|
print_exc()
|
||||||
raise e
|
raise e
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -228,7 +231,7 @@ class SQLor(object):
|
|||||||
sql1 = cc.convert(sql1,NS)
|
sql1 = cc.convert(sql1,NS)
|
||||||
vars = sqlargsAC.findAllVariables(sql1)
|
vars = sqlargsAC.findAllVariables(sql1)
|
||||||
phnamespace = {}
|
phnamespace = {}
|
||||||
[phnamespace.update({v:self.placeHolder(v,i)}) for v,i in enumerate(vars)]
|
[phnamespace.update({v:self.placeHolder(v,i)}) for i,v in enumerate(vars)]
|
||||||
m_sql = sqlargsAC.convert(sql1,phnamespace)
|
m_sql = sqlargsAC.convert(sql1,phnamespace)
|
||||||
newdata = []
|
newdata = []
|
||||||
for v in vars:
|
for v in vars:
|
||||||
|
Loading…
Reference in New Issue
Block a user