Created
April 25, 2014 07:27
-
-
Save tg123/11280667 to your computer and use it in GitHub Desktop.
mysql create table to java pojo field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import re | |
# http://stackoverflow.com/questions/4303492/how-can-i-simplify-this-conversion-from-underscore-to-camelcase-in-python | |
def underscore_to_camelcase(value): | |
def camelcase(): | |
yield str.lower | |
while True: | |
yield str.capitalize | |
c = camelcase() | |
return "".join(c.next()(x) if x else '_' for x in value.split("_")) | |
M = { | |
'int': 'long', | |
'varchar' : 'String', | |
'datetime' : 'Date', | |
} | |
ACC = 'private' | |
for f, t in re.findall('`(.*?)` (.*?)\(?\d*\)? ', sys.stdin.read()): | |
f = underscore_to_camelcase(f) | |
print ACC, M[t], f + ';' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment