'Field info returned from a "show columns from table"-query.
Each table object has a Table.schema{} dictionary describing the fields\' structure.'

def __init__(self, name, type, default=None, index=False, optional=True, extra=None):

    (type, length) = (type.lower(), None)
    if type.startswith(('varchar', 'char')):
        length = type.split('(')[(-1)].strip(')')
        length = int(length)
        type = STRING
    if type.startswith('int'):
        type = INTEGER
    if type.startswith(('real', 'double')):
        type = FLOAT
    if type.startswith('time'):
        type = DATE
    if type.startswith('text'):
        type = TEXT
    if type.startswith('blob'):
        type = BLOB
    if type.startswith('tinyint(1)'):
        type = BOOLEAN
    if isinstance(index, basestring):
        if index.lower().startswith('pri'):
            index = PRIMARY
        if index.lower().startswith('uni'):
            index = UNIQUE
        if (index.lower() in ('0', '1', '', 'yes', 'mul')):
            index = (index.lower() in ('1', 'yes', 'mul'))
    if (isinstance(default, basestring) and (type == DATE)):
        default = default.strip("'")
        default = default.replace('current_timestamp', NOW)
        default = default.replace('CURRENT_TIMESTAMP', NOW)
    if ((default is not None) and (type == INTEGER)):
        default = int(default)
    if ((default is not None) and (type == FLOAT)):
        default = float(default)
    if ((not default) and (default != 0)):
        default = None
    self.name = name
    self.type = type
    self.length = length
    self.default = default
    self.index = index
    self.optional = (str(optional) in ('0', 'True', 'YES'))
    self.extra = (extra or None)
