Package web2py :: Package gluon :: Module sql_old :: Class SQLCustomType
[hide private]
[frames] | no frames]

Class SQLCustomType

source code


allows defining of custom SQL types

Example::

    decimal = SQLCustomType(
        type ='double',
        native ='integer',
        encoder =(lambda x: int(float(x) * 100)),
        decoder = (lambda x: Decimal("0.00") + Decimal(str(float(x)/100)) )
        )

    db.define_table(
        'example',
        Field('value', type=decimal)
        )

:param type: the web2py type (default = 'string')
:param native: the backend type
:param encoder: how to encode the value to store it in the backend
:param decoder: how to decode the value retrieved from the backend
:param validator: what validators to use ( default = None, will use the
    default validator for type)



Instance Methods [hide private]
 
__init__(self, type='string', native=1, encoder=1, decoder=1, validator=1, _class=1) source code
 
startswith(self, dummy=1) source code
 
__getslice__(self, a=0, b=100) source code
 
__getitem__(self, i) source code
 
__str__(self) source code