def get_field_type(model, fieldname):
 field = getattr(model, fieldname)
 if isinstance(field, ColumnElement):
  return field.type
 if isinstance(field, AssociationProxy):
  field = field.remote_attr
 if hasattr(field, 'property'):
  prop = field.property
  if isinstance(prop, RelProperty):
   return None
  return prop.columns[0].type
 return None

def get_field_type ( model , fieldname ) : field = getattr ( model , fieldname ) if isinstance ( field , ColumnElement ) : return field . type if isinstance ( field , AssociationProxy ) : field = field . remote_attr if hasattr ( field , 'property' ) : prop = field . property if isinstance ( prop , RelProperty ) : return None return prop . columns [ 0 ] . type return None
given the database connection .