Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions sqlconvert.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ def fielddef(row):
}
c=row.find('comment')
if c is not None:
newattrs=dict([
i.split('="') for i in c.text.replace('",','|||')[:-1].split('|||')
])
ctext = c.text.replace('",','|||')[:-1].split('|||')
newattrs={}
for i in ctext:
try:
key, val = i.split('="')
newattrs[key] = val
except Exception as e:
raise ValueError("Comment doesn't contain '=\"': %s" % repr(i) )
if 'type' in newattrs:
newattrs['type']="'%s'" % newattrs['type']
attrs.update(newattrs)
Expand All @@ -45,7 +50,7 @@ def convert(xml):
text=""
for table in xml.findall('table'):
text+="db.define_table('%s',\n" % table.get('name')
for row in table.findall('row'):
for row in table.findall('row'):
row=fielddef(row)
if row['name']!='id':
if row['type']=="'string'":
Expand Down