Did I find the right examples for you? yes no

All Samples(9)  |  Call(7)  |  Derive(0)  |  Import(2)
Convert a column name to a Human Readable name.
borrowed from old TG fastdata code

        def name2label(name, schema=None):
    """
    Convert a column name to a Human Readable name.
    borrowed from old TG fastdata code
    """
    # Create label from the name:
    #   1) Convert _ to Nothing
    #   2) Convert CamelCase to Camel Case
    #   3) Upcase first character of Each Word
    # Note: I *think* it would be thread-safe to
    #       memoize this thing.
    if schema:
        if name.startswith(schema+'.'):
            name = '.'.join(name.split('.')[1:])
    label = str(''.join([s.capitalize() for s in
               re.findall(r'([A-Z][a-z0-9]+|[a-z0-9]+|[A-Z0-9]+)', name)]))
    return label
        


src/s/q/sqlautocode-0.7/sqlautocode/declarative.py   sqlautocode(Download)
import sys, re, inspect, operator
import logging
from util import emit, name2label, plural, singular
try:
    from cStringIO import StringIO
        log.debug('Creating Model from table: %s'%table.name)
 
        model_name = self.find_new_name(singular(name2label(table.name)), self.used_model_names)
        self.used_model_names.append(model_name)
        is_many_to_many_table = self.is_many_to_many_table(table)
            log.info('    Adding <primary> foreign key for:%s'%related_table.name)
            backref_name = plural(table_name)
            rel = relation(singular(name2label(related_table.name, related_table.schema)), 
                           primaryjoin=column==fk.column)#, backref=backref_name)
 
                if len(constraint.elements) >1:
                    related_table = constraint.elements[0].column.table
                    related_classname = singular(name2label(related_table.name, related_table.schema))
 
                    primary_join = "and_(%s)"%', '.join(["%s.%s==%s.%s"%(model_name,
                        log.info('    Adding <secondary> foreign key(%s) for:%s'%(key, related_table.name))
                        setattr(Temporal, plural(related_table.name), _deferred_relationship(Temporal,
                                                                                         relation(singular(name2label(related_table.name,
                                                                                                             related_table.schema)),
                                                                                                  secondary=join_table,

src/s/q/sqlautocode-HEAD/sqlautocode/declarative.py   sqlautocode(Download)
import sys, re, inspect, operator
import logging
from util import emit, name2label, plural, singular
try:
    from cStringIO import StringIO
        log.debug('Creating Model from table: %s'%table.name)
 
        model_name = self.find_new_name(singular(name2label(table.name)), self.used_model_names)
        self.used_model_names.append(model_name)
        is_many_to_many_table = self.is_many_to_many_table(table)
            backref_name = plural(table_name)
#            import ipdb; ipdb.set_trace()
            rel = relation(singular(name2label(related_table.name, related_table.schema)), 
                           primaryjoin=column==column.foreign_keys[0].column)#, backref=backref_name)
            setattr(Temporal, related_table.name, _deferred_relationship(Temporal, rel))
#                        import ipdb; ipdb.set_trace()
                        setattr(Temporal, plural(related_table.name), _deferred_relationship(Temporal,
                                                                                         relation(singular(name2label(related_table.name,
                                                                                                             related_table.schema)),
                                                                                                  secondary=join_table,