#NEWLINE# def get_indicator_model( name , indicator_doc ) : #NEWLINE# #INDENT# columns = [ sqlalchemy . Column ( 'doc_id' , sqlalchemy . Unicode ( 255 ) , nullable = False , primary_key = True ) , sqlalchemy . Column ( 'date' , sqlalchemy . Date , nullable = False , primary_key = True ) ] #NEWLINE# try : #NEWLINE# #INDENT# flat_fields = indicator_doc . _flat_fields #NEWLINE# for flat_name in flat_fields . keys ( ) : #NEWLINE# #INDENT# columns . append ( sqlalchemy . Column ( flat_name , sqlalchemy . String , nullable = True ) ) #NEWLINE# #UNINDENT# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# group_types = indicator_doc . get_group_types ( ) #NEWLINE# for group_name in indicator_doc . get_group_names ( ) : #NEWLINE# #INDENT# columns . append ( sqlalchemy . Column ( group_name , get_column_type ( group_types [ group_name ] ) , nullable = False , primary_key = True ) ) #NEWLINE# #UNINDENT# calculators = indicator_doc . _calculators #NEWLINE# for calc_name in sorted ( calculators . keys ( ) ) : #NEWLINE# #INDENT# for emitter_name in calculators [ calc_name ] . _fluff_emitters : #NEWLINE# #INDENT# col_name = '{0}_{1}' . format ( calc_name , calculators ) #NEWLINE# columns . append ( sqlalchemy . Column ( col_name , sqlalchemy . Integer , nullable = True ) ) #NEWLINE# #UNINDENT# #UNINDENT# return sqlalchemy . Table ( 'fluff_{0}' . format ( name ) , metadata , * columns )