-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsql2go.py
More file actions
30 lines (28 loc) · 747 Bytes
/
Copy pathsql2go.py
File metadata and controls
30 lines (28 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def to_goname(name):
ss = name.split('_')
goname = ''
for s in ss:
if s in ["id", "uid", "url"]:
goname = goname + s.upper()
else:
goname = goname + s.capitalize()
return goname
for x in open("/tmp/tt"):
x = x.strip()
xs = x.split(' ')
column = xs[0]
goname = to_goname(column)
gotype = ''
type = xs[1].lower()
if 'bigint' in type:
gotype = 'int64'
elif 'int' in type:
gotype = 'int'
elif 'char' in type:
gotype = 'string'
elif 'float' in type or 'double' in type:
gotype = 'float64'
else:
continue
comment = x[x.index(' ')+1:]
print '\t%s %s `ddb:"%s"` // %s' % (goname, gotype, column, comment)