Python sqlalchemy.types 模块,CHAR 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用sqlalchemy.types.CHAR

项目:TopChef    作者:TopChef    | 项目源码 | 文件源码
def load_dialect_impl(self, dialect: dialects) -> DialectType:
        """
        SQLAlchemy wraps all database-specific features into
        dialects, which are then responsible for generating the SQL code
        for a specific DB type when loading in data. ``load_dialect_impl``
        is called when CRUD (create, update, delete operations) needs to be
        done on the database. This method is responsible for telling
        SQLAlchemy how to configure the dialect to write this type

        :param dialect: The loaded dialect
        :return: The type descriptor for this type.
        """
        if dialect.name == 'postgresql':
            return dialect.type_descriptor(postgresql.UUID())
        else:
            return dialect.type_descriptor(CHAR(32))
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def __init__(self, length=None, **kwargs):
        super(CHAR, self).__init__(length=length, **kwargs)
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def normalize_name(self, name):
        # Remove trailing spaces: FB uses a CHAR() type,
        # that is padded with spaces
        name = name and name.rstrip()
        if name is None:
            return None
        elif name.upper() == name and \
                not self.identifier_preparer._requires_quotes(name.lower()):
            return name.lower()
        else:
            return name
项目:annotated-py-sqlalchemy    作者:hhstore    | 项目源码 | 文件源码
def get_col_spec(self):
        return "CHAR(%(length)s)" % {'length' : self.length}
项目:annotated-py-sqlalchemy    作者:hhstore    | 项目源码 | 文件源码
def get_col_spec(self):
        return "CHAR(%(length)s)" % {'length' : self.length}
项目:annotated-py-sqlalchemy    作者:hhstore    | 项目源码 | 文件源码
def get_col_spec(self):
        return "CHAR(%(length)s)" % {'length' : self.length}
项目:annotated-py-sqlalchemy    作者:hhstore    | 项目源码 | 文件源码
def get_col_spec(self):
        return "CHAR(%(length)s)" % {'length' : self.length}
项目:Brightside    作者:BrighterCommand    | 项目源码 | 文件源码
def load_dialect_impl(self, dialect):
        if dialect.name == 'postgresql':
            return dialect.type_descriptor(UUID())
        else:
            return dialect.type_descriptor(CHAR(32))
项目:QXSConsolas    作者:qxsch    | 项目源码 | 文件源码
def __init__(self, length=None, **kwargs):
        super(CHAR, self).__init__(length=length, **kwargs)
项目:QXSConsolas    作者:qxsch    | 项目源码 | 文件源码
def normalize_name(self, name):
        # Remove trailing spaces: FB uses a CHAR() type,
        # that is padded with spaces
        name = name and name.rstrip()
        if name is None:
            return None
        elif name.upper() == name and \
                not self.identifier_preparer._requires_quotes(name.lower()):
            return name.lower()
        else:
            return name
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def __init__(self, length=None, **kwargs):
        super(CHAR, self).__init__(length=length, **kwargs)
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def normalize_name(self, name):
        # Remove trailing spaces: FB uses a CHAR() type,
        # that is padded with spaces
        name = name and name.rstrip()
        if name is None:
            return None
        elif name.upper() == name and \
                not self.identifier_preparer._requires_quotes(name.lower()):
            return name.lower()
        else:
            return name
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def __init__(self, length=None, **kwargs):
        """Construct a CHAR.

        :param length: Maximum data length, in characters.

        :param binary: Optional, use the default binary collation for the
          national character set.  This does not affect the type of data
          stored, use a BINARY type for binary data.

        :param collation: Optional, request a particular collation.  Must be
          compatible with the national character set.

        """

        super(CHAR, self).__init__(length=length, **kwargs)
项目:Python_Study    作者:thsheep    | 项目源码 | 文件源码
def key_deal():
    from_ = Column('from', CHAR(10))

#??????
#Column?????????????????????
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def __init__(self, length=None, **kwargs):
        super(CHAR, self).__init__(length=length, **kwargs)
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def normalize_name(self, name):
        # Remove trailing spaces: FB uses a CHAR() type,
        # that is padded with spaces
        name = name and name.rstrip()
        if name is None:
            return None
        elif name.upper() == name and \
                not self.identifier_preparer._requires_quotes(name.lower()):
            return name.lower()
        else:
            return name
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def __init__(self, length=None, **kwargs):
        """Construct a CHAR.

        :param length: Maximum data length, in characters.

        :param binary: Optional, use the default binary collation for the
          national character set.  This does not affect the type of data
          stored, use a BINARY type for binary data.

        :param collation: Optional, request a particular collation.  Must be
          compatible with the national character set.

        """

        super(CHAR, self).__init__(length=length, **kwargs)
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def __init__(self, length=None, **kwargs):
        super(CHAR, self).__init__(length=length, **kwargs)
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def normalize_name(self, name):
        # Remove trailing spaces: FB uses a CHAR() type,
        # that is padded with spaces
        name = name and name.rstrip()
        if name is None:
            return None
        elif name.upper() == name and \
                not self.identifier_preparer._requires_quotes(name.lower()):
            return name.lower()
        else:
            return name
项目:ShelbySearch    作者:Agentscreech    | 项目源码 | 文件源码
def __init__(self, length=None, **kwargs):
        super(CHAR, self).__init__(length=length, **kwargs)
项目:ShelbySearch    作者:Agentscreech    | 项目源码 | 文件源码
def normalize_name(self, name):
        # Remove trailing spaces: FB uses a CHAR() type,
        # that is padded with spaces
        name = name and name.rstrip()
        if name is None:
            return None
        elif name.upper() == name and \
                not self.identifier_preparer._requires_quotes(name.lower()):
            return name.lower()
        elif name.lower() == name:
            return quoted_name(name, quote=True)
        else:
            return name
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
def __init__(self, length=None, **kwargs):
        super(CHAR, self).__init__(length=length, **kwargs)
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
def normalize_name(self, name):
        # Remove trailing spaces: FB uses a CHAR() type,
        # that is padded with spaces
        name = name and name.rstrip()
        if name is None:
            return None
        elif name.upper() == name and \
            not self.identifier_preparer._requires_quotes(name.lower()):
            return name.lower()
        else:
            return name
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
def __init__(self, length=None, **kwargs):
        """Construct a CHAR.

        :param length: Maximum data length, in characters.

        :param binary: Optional, use the default binary collation for the
          national character set.  This does not affect the type of data
          stored, use a BINARY type for binary data.

        :param collation: Optional, request a particular collation.  Must be
          compatible with the national character set.

        """

        super(CHAR, self).__init__(length=length, **kwargs)
项目:Price-Comparator    作者:Thejas-1    | 项目源码 | 文件源码
def __init__(self, length=None, **kwargs):
        super(CHAR, self).__init__(length=length, **kwargs)
项目:Price-Comparator    作者:Thejas-1    | 项目源码 | 文件源码
def normalize_name(self, name):
        # Remove trailing spaces: FB uses a CHAR() type,
        # that is padded with spaces
        name = name and name.rstrip()
        if name is None:
            return None
        elif name.upper() == name and \
                not self.identifier_preparer._requires_quotes(name.lower()):
            return name.lower()
        else:
            return name
项目:TopChef    作者:TopChef    | 项目源码 | 文件源码
def test_name_sqlite(self) -> None:
        """
        Tests that if the name ``sqlite`` is given to the database, then a
        CHAR descriptor comes back out with 32 characters
        """
        uuid_instance = DB_UUID()
        dialect_impl = uuid_instance.load_dialect_impl(self.sqlite_dialect)
        self.assertIsInstance(
            dialect_impl, self.sqlite_dialect.type_descriptor(
                CHAR(32)
            ).__class__
        )
项目:TopChef    作者:TopChef    | 项目源码 | 文件源码
def test_bind_uuid_something_else(self, uuid: UUID) -> None:
        """
        Tests that the UUID gets de-hyphenated if using the CHAR 32 type, same
        as always.

        :param uuid: A randomly-generated UUID to store
        """
        db_uuid = DB_UUID()
        value_to_store = db_uuid.process_bind_param(
            uuid, self.sqlite_dialect
        )
        self.assertEqual(
            value_to_store, "%.32x" % int(uuid)
        )
项目:quark    作者:openstack    | 项目源码 | 文件源码
def load_dialect_impl(self, dialect):
        # IPv6 is 128 bits => 2^128 == 3.4e38 => 39 digits
        return dialect.type_descriptor(types.CHAR(39))
项目:quark    作者:openstack    | 项目源码 | 文件源码
def load_dialect_impl(self, dialect):
        if dialect.name == 'sqlite':
            return dialect.type_descriptor(sqlite.CHAR)
        return dialect.type_descriptor(self.impl)
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def __init__(self, length=None, **kwargs):
        super(CHAR, self).__init__(length=length, **kwargs)
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def normalize_name(self, name):
        # Remove trailing spaces: FB uses a CHAR() type,
        # that is padded with spaces
        name = name and name.rstrip()
        if name is None:
            return None
        elif name.upper() == name and \
                not self.identifier_preparer._requires_quotes(name.lower()):
            return name.lower()
        else:
            return name
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def __init__(self, length=None, **kwargs):
        super(CHAR, self).__init__(length=length, **kwargs)
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def normalize_name(self, name):
        # Remove trailing spaces: FB uses a CHAR() type,
        # that is padded with spaces
        name = name and name.rstrip()
        if name is None:
            return None
        elif name.upper() == name and \
                not self.identifier_preparer._requires_quotes(name.lower()):
            return name.lower()
        else:
            return name
项目:Callandtext    作者:iaora    | 项目源码 | 文件源码
def __init__(self, length=None, **kwargs):
        super(CHAR, self).__init__(length=length, **kwargs)
项目:Callandtext    作者:iaora    | 项目源码 | 文件源码
def normalize_name(self, name):
        # Remove trailing spaces: FB uses a CHAR() type,
        # that is padded with spaces
        name = name and name.rstrip()
        if name is None:
            return None
        elif name.upper() == name and \
                not self.identifier_preparer._requires_quotes(name.lower()):
            return name.lower()
        else:
            return name
项目:python_ddd_flask    作者:igorvinnicius    | 项目源码 | 文件源码
def __init__(self, length=None, **kwargs):
        super(CHAR, self).__init__(length=length, **kwargs)
项目:python_ddd_flask    作者:igorvinnicius    | 项目源码 | 文件源码
def normalize_name(self, name):
        # Remove trailing spaces: FB uses a CHAR() type,
        # that is padded with spaces
        name = name and name.rstrip()
        if name is None:
            return None
        elif name.upper() == name and \
                not self.identifier_preparer._requires_quotes(name.lower()):
            return name.lower()
        else:
            return name
项目:zeus    作者:getsentry    | 项目源码 | 文件源码
def load_dialect_impl(self, dialect):
        if dialect.name == 'postgresql':
            return dialect.type_descriptor(UUID())
        else:
            return dialect.type_descriptor(CHAR(32))
项目:parade    作者:bailaohe    | 项目源码 | 文件源码
def sqltype_to_stdtype(sqltype):
    import sqlalchemy.types as sqltypes
    if isinstance(sqltype, (sqltypes.VARCHAR, sqltypes.CHAR, sqltypes.TEXT, sqltypes.Enum, sqltypes.String)):
        return _STRING_TYPE
    if isinstance(sqltype, (sqltypes.DATETIME, sqltypes.DATE, sqltypes.TIME, sqltypes.TIMESTAMP)):
        return _DATE_TYPE
    if isinstance(sqltype, (sqltypes.INTEGER, sqltypes.BIGINT, sqltypes.SMALLINT, sqltypes.Integer)):
        return _INTEGER_TYPE
    if isinstance(sqltype, (sqltypes.REAL, sqltypes.DECIMAL, sqltypes.NUMERIC, sqltypes.FLOAT)):
        return _DECIMAL_TYPE
    if isinstance(sqltype, sqltypes.BOOLEAN):
        return _BOOLEAN_TYPE
项目:rucio    作者:rucio01    | 项目源码 | 文件源码
def load_dialect_impl(self, dialect):
        if dialect.name == 'postgresql':
            return dialect.type_descriptor(UUID())
        elif dialect.name == 'oracle':
            return dialect.type_descriptor(RAW(16))
        elif dialect.name == 'mysql':
            return dialect.type_descriptor(BINARY(16))
        else:
            return dialect.type_descriptor(CHAR(32))
项目:webapp    作者:superchilli    | 项目源码 | 文件源码
def __init__(self, length=None, **kwargs):
        super(CHAR, self).__init__(length=length, **kwargs)
项目:webapp    作者:superchilli    | 项目源码 | 文件源码
def normalize_name(self, name):
        # Remove trailing spaces: FB uses a CHAR() type,
        # that is padded with spaces
        name = name and name.rstrip()
        if name is None:
            return None
        elif name.upper() == name and \
                not self.identifier_preparer._requires_quotes(name.lower()):
            return name.lower()
        elif name.lower() == name:
            return quoted_name(name, quote=True)
        else:
            return name
项目:QualquerMerdaAPI    作者:tiagovizoto    | 项目源码 | 文件源码
def __init__(self, length=None, **kwargs):
        super(CHAR, self).__init__(length=length, **kwargs)
项目:QualquerMerdaAPI    作者:tiagovizoto    | 项目源码 | 文件源码
def normalize_name(self, name):
        # Remove trailing spaces: FB uses a CHAR() type,
        # that is padded with spaces
        name = name and name.rstrip()
        if name is None:
            return None
        elif name.upper() == name and \
                not self.identifier_preparer._requires_quotes(name.lower()):
            return name.lower()
        elif name.lower() == name:
            return quoted_name(name, quote=True)
        else:
            return name
项目:gardenbot    作者:GoestaO    | 项目源码 | 文件源码
def __init__(self, length=None, **kwargs):
        super(CHAR, self).__init__(length=length, **kwargs)
项目:gardenbot    作者:GoestaO    | 项目源码 | 文件源码
def normalize_name(self, name):
        # Remove trailing spaces: FB uses a CHAR() type,
        # that is padded with spaces
        name = name and name.rstrip()
        if name is None:
            return None
        elif name.upper() == name and \
                not self.identifier_preparer._requires_quotes(name.lower()):
            return name.lower()
        elif name.lower() == name:
            return quoted_name(name, quote=True)
        else:
            return name
项目:flask-zhenai-mongo-echarts    作者:Fretice    | 项目源码 | 文件源码
def __init__(self, length=None, **kwargs):
        super(CHAR, self).__init__(length=length, **kwargs)
项目:flask-zhenai-mongo-echarts    作者:Fretice    | 项目源码 | 文件源码
def normalize_name(self, name):
        # Remove trailing spaces: FB uses a CHAR() type,
        # that is padded with spaces
        name = name and name.rstrip()
        if name is None:
            return None
        elif name.upper() == name and \
                not self.identifier_preparer._requires_quotes(name.lower()):
            return name.lower()
        elif name.lower() == name:
            return quoted_name(name, quote=True)
        else:
            return name
项目:deb-python-sqlalchemy-utils    作者:openstack    | 项目源码 | 文件源码
def __init__(self, binary=True, native=True):
        """
        :param binary: Whether to use a BINARY(16) or CHAR(32) fallback.
        """
        self.binary = binary
        self.native = native