def table_add_column(table, name, col_type, session, default=None):
 if isinstance(table, basestring):
  table = table_schema(table, session)
 if (name in table_columns(table, session)):
  return
 if (not isinstance(col_type, TypeEngine)):
  col_type = col_type()
 type_string = session.bind.engine.dialect.type_compiler.process(col_type)
 statement = (u'ALTER TABLE %s ADD %s %s' % (table.name, name, type_string))
 session.execute(statement)
 if (default is not None):
  table = table_schema(table.name, session)
  if (not isinstance(default, (ColumnDefault, Sequence))):
   default = ColumnDefault(default)
  default._set_parent(getattr(table.c, name))
  statement = table.update().values({name: default.execute(bind=session.bind)})
  session.execute(statement)

def table_add_column ( table , name , col_type , session , default = None ) : if isinstance ( table , basestring ) : table = table_schema ( table , session ) if ( name in table_columns ( table , session ) ) : return if ( not isinstance ( col_type , TypeEngine ) ) : col_type = col_type ( ) type_string = session . bind . engine . dialect . type_compiler . process ( col_type ) statement = ( u'ALTER TABLE %s ADD %s %s' % ( table . name , name , type_string ) ) session . execute ( statement ) if ( default is not None ) : table = table_schema ( table . name , session ) if ( not isinstance ( default , ( ColumnDefault , Sequence ) ) ) : default = ColumnDefault ( default ) default . _set_parent ( getattr ( table . c , name ) ) statement = table . update ( ) . values ( { name : default . execute ( bind = session . bind ) } ) session . execute ( statement )
adds a column to a table .