How to use the sqlobject.col.Col function in SQLObject

To help you get started, we’ve selected a few SQLObject examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sqlobject / sqlobject / sqlobject / postgres / pgconnection.py View on Github external
elif t.count('float') or t.count('real') or t.count('double'):
            return col.FloatCol, {}
        elif t == 'text':
            return col.StringCol, {}
        elif t.startswith('timestamp'):
            return col.DateTimeCol, {}
        elif t.startswith('datetime'):
            return col.DateTimeCol, {}
        elif t.startswith('date'):
            return col.DateCol, {}
        elif t.startswith('bool'):
            return col.BoolCol, {}
        elif t.startswith('bytea'):
            return col.BLOBCol, {}
        else:
            return col.Col, {}
github sqlobject / sqlobject / sqlobject / firebird / firebirdconnection.py View on Github external
else:
                return col.StringCol, {'length': flength, 'varchar': False}
        elif t == 'varchar':  # 32767 bytes
            if fCharset and (fCharset != "NONE"):
                return col.UnicodeCol, {'length': flength, 'varchar': True,
                                        'dbEncoding': fCharset}
            elif self.dbEncoding:
                return col.UnicodeCol, {'length': flength, 'varchar': True,
                                        'dbEncoding': self.dbEncoding}
            else:
                return col.StringCol, {'length': flength, 'varchar': True}

        elif t == 'blob':  # 32GB
            return col.BLOBCol, {}
        else:
            return col.Col, {}
github sqlobject / sqlobject / sqlobject / col.py View on Github external
return [JSONValidator(name=self.name)] + \
            super(SOJSONCol, self).createValidators()


class JSONCol(StringCol):
    baseClass = SOJSONCol


def pushKey(kw, name, value):
    if name not in kw:
        kw[name] = value

all = []
# Use copy() to avoid 'dictionary changed' issues on python 3
for key, value in globals().copy().items():
    if isinstance(value, type) and (issubclass(value, (Col, SOCol))):
        all.append(key)
__all__.extend(all)
del all
github stoq / stoq / external / sqlobject / postgres / pgconnection.py View on Github external
elif t.count('float') or t.count('real') or t.count('double'):
            return col.FloatCol, {}
        elif t == 'text':
            return col.StringCol, {}
        elif t.startswith('timestamp'):
            return col.DateTimeCol, {}
        elif t.startswith('datetime'):
            return col.DateTimeCol, {}
        elif t.startswith('date'):
            return col.DateCol, {}
        elif t.startswith('bool'):
            return col.BoolCol, {}
        elif t.startswith('bytea'):
            return col.BLOBCol, {}
        else:
            return col.Col, {}
github sqlobject / sqlobject / sqlobject / col.py View on Github external
return self.key_type[self._idType()]

    def _sybaseType(self):
        key_type = {int: "NUMERIC(18,0)", str: "TEXT"}
        return key_type[self._idType()]

    def _mssqlType(self):
        key_type = {int: "INT", str: "TEXT"}
        return key_type[self._idType()]

    def _firebirdType(self):
        key_type = {int: "INT", str: "VARCHAR(255)"}
        return key_type[self._idType()]


class KeyCol(Col):

    baseClass = SOKeyCol


class ForeignKeyValidator(SOValidator):

    def __init__(self, *args, **kw):
        super(ForeignKeyValidator, self).__init__(*args, **kw)
        self.fkIDType = None

    def from_python(self, value, state):
        if value is None:
            return None
        # Avoid importing the main module
        # to get the SQLObject class for isinstance
        if hasattr(value, 'sqlmeta'):
github sqlobject / sqlobject / sqlobject / mssql / mssqlconnection.py View on Github external
return col.UnicodeCol, {'length': size}
            return col.StringCol, {'length': size}
        elif t.startswith('char'):
            if self.usingUnicodeStrings:
                return col.UnicodeCol, {'length': size,
                                        'varchar': False}
            return col.StringCol, {'length': size,
                                   'varchar': False}
        elif t.startswith('datetime'):
            return col.DateTimeCol, {}
        elif t.startswith('decimal'):
            # be careful for awkward naming
            return col.DecimalCol, {'size': precision,
                                    'precision': scale}
        else:
            return col.Col, {}
github sqlobject / sqlobject / sqlobject / col.py View on Github external
if self.connection and self.connection.can_use_microseconds():
            return 'TIME(6)'
        else:
            return 'TIME'

    def _sqliteType(self):
        return 'TIME'

    def _firebirdType(self):
        return 'TIME'

    def _maxdbType(self):
        return 'TIME'


class TimeCol(Col):
    baseClass = SOTimeCol


class SOTimestampCol(SODateTimeCol):
    """
    Necessary to support MySQL's use of TIMESTAMP versus DATETIME types
    """

    def __init__(self, **kw):
        if 'default' not in kw:
            kw['default'] = None
        SOCol.__init__(self, **kw)

    def _mysqlType(self):
        if self.connection and self.connection.can_use_microseconds():
            return 'TIMESTAMP(6)'
github sqlobject / sqlobject / sqlobject / main.py View on Github external
def __classinit__(cls, new_attrs):

        # This is true if we're initializing the SQLObject class,
        # instead of a subclass:
        is_base = cls.__bases__ == (object,)

        cls._SO_setupSqlmeta(new_attrs, is_base)

        implicitColumns = _collectAttributes(cls, new_attrs, col.Col)
        implicitJoins = _collectAttributes(cls, new_attrs, joins.Join)
        implicitIndexes = _collectAttributes(cls, new_attrs,
                                             index.DatabaseIndex)

        if not is_base:
            cls._SO_cleanDeprecatedAttrs(new_attrs)

        if '_connection' in new_attrs:
            connection = new_attrs['_connection']
            del cls._connection
            assert 'connection' not in new_attrs
        elif 'connection' in new_attrs:
            connection = new_attrs['connection']
            del cls.connection
        else:
            connection = None
github sqlobject / sqlobject / sqlobject / col.py View on Github external
class SOSmallIntCol(SOIntCol):
    def _sqlType(self):
        return self.addSQLAttrs("SMALLINT")


class SmallIntCol(Col):
    baseClass = SOSmallIntCol


class SOMediumIntCol(SOIntCol):
    def _sqlType(self):
        return self.addSQLAttrs("MEDIUMINT")


class MediumIntCol(Col):
    baseClass = SOMediumIntCol


class SOBigIntCol(SOIntCol):
    def _sqlType(self):
        return self.addSQLAttrs("BIGINT")


class BigIntCol(Col):
    baseClass = SOBigIntCol


class BoolValidator(SOValidator):

    def to_python(self, value, state):
        if value is None: