@@ -160,13 +160,15 @@ def _render_column(column, show_name):
160160 if column .server_default :
161161 server_default = 'server_default=' + _flask_prepend + 'FetchedValue()'
162162
163+ comment = getattr (column , 'comment' , None )
163164 return _flask_prepend + 'Column({0})' .format (', ' .join (
164165 ([repr (column .name )] if show_name else []) +
165166 ([_render_column_type (column .type )] if render_coltype else []) +
166167 [_render_constraint (x ) for x in dedicated_fks ] +
167168 [repr (x ) for x in column .constraints ] +
168169 ['{0}={1}' .format (k , repr (getattr (column , k ))) for k in kwarg ] +
169- ([server_default ] if column .server_default else [])
170+ ([server_default ] if column .server_default else []) +
171+ (['info={!r}' .format (comment )] if comment else [])
170172 ))
171173
172174
@@ -527,7 +529,7 @@ class CodeGenerator(object):
527529
528530 def __init__ (self , metadata , noindexes = False , noconstraints = False ,
529531 nojoined = False , noinflect = False , nobackrefs = False ,
530- flask = False , ignore_cols = None , noclasses = False ):
532+ flask = False , ignore_cols = None , noclasses = False , nocomments = False ):
531533 super (CodeGenerator , self ).__init__ ()
532534
533535 if noinflect :
@@ -544,6 +546,8 @@ def __init__(self, metadata, noindexes=False, noconstraints=False,
544546 global _flask_prepend
545547 _flask_prepend = ''
546548
549+ self .nocomments = nocomments
550+
547551 # Pick association tables from the metadata into their own set, don't process them normally
548552 links = defaultdict (lambda : [])
549553 association_tables = set ()
@@ -654,7 +658,7 @@ def render(self, outfile=sys.stdout):
654658 # Render the model tables and classes
655659 for model in self .models :
656660 print ('\n \n ' , file = outfile )
657- print (model .render ().rstrip ('\n ' ). encode ( 'utf-8' ) , file = outfile )
661+ print (model .render ().rstrip ('\n ' ), file = outfile )
658662
659663 if self .footer :
660664 print (self .footer , file = outfile )
0 commit comments