当前位置: 首页>>代码示例>>Python>>正文


Python types.CHAR属性代码示例

本文整理汇总了Python中sqlalchemy.types.CHAR属性的典型用法代码示例。如果您正苦于以下问题:Python types.CHAR属性的具体用法?Python types.CHAR怎么用?Python types.CHAR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在sqlalchemy.types的用法示例。


在下文中一共展示了types.CHAR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_no_convert_unicode

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import CHAR [as 别名]
def test_no_convert_unicode(self):
        """test no utf-8 encoding occurs"""

        dialect = sqlite.dialect()
        for t in (
            String(),
            sqltypes.CHAR(),
            sqltypes.Unicode(),
            sqltypes.UnicodeText(),
            String(),
            sqltypes.CHAR(),
            sqltypes.Unicode(),
            sqltypes.UnicodeText(),
        ):
            bindproc = t.dialect_impl(dialect).bind_processor(dialect)
            assert not bindproc or isinstance(
                bindproc(util.u("some string")), util.text_type
            ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:20,代码来源:test_sqlite.py

示例2: __init__

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import CHAR [as 别名]
def __init__(self, length=None, **kwargs):
        super(CHAR, self).__init__(length=length, **kwargs) 
开发者ID:jpush,项目名称:jbox,代码行数:4,代码来源:base.py

示例3: normalize_name

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import CHAR [as 别名]
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 
开发者ID:jpush,项目名称:jbox,代码行数:13,代码来源:base.py

示例4: load_dialect_impl

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import CHAR [as 别名]
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)) 
开发者ID:rucio,项目名称:rucio,代码行数:11,代码来源:types.py

示例5: load_dialect_impl

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import CHAR [as 别名]
def load_dialect_impl(self, dialect):
        if dialect.name == 'postgresql':
            return dialect.type_descriptor(pgUUID())
        else:
            return dialect.type_descriptor(CHAR(32)) 
开发者ID:openstack,项目名称:designate,代码行数:7,代码来源:types.py

示例6: load_dialect_impl

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import CHAR [as 别名]
def load_dialect_impl(self, dialect: Any) -> Any:
        if dialect.name == "postgresql":
            return dialect.type_descriptor(UUID())
        else:
            return dialect.type_descriptor(CHAR(32)) 
开发者ID:Enforcer,项目名称:clean-architecture,代码行数:7,代码来源:__init__.py

示例7: load_dialect_impl

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import CHAR [as 别名]
def load_dialect_impl(self, dialect):
        if dialect.name == 'postgresql':
            return dialect.type_descriptor(UUID())
        else:
            return dialect.type_descriptor(CHAR(32)) 
开发者ID:cmdmnt,项目名称:commandment,代码行数:7,代码来源:dbtypes.py

示例8: normalize_name

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import CHAR [as 别名]
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 
开发者ID:yfauser,项目名称:planespotter,代码行数:15,代码来源:base.py

示例9: sqltype_to_stdtype

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import CHAR [as 别名]
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 
开发者ID:bailaohe,项目名称:parade,代码行数:14,代码来源:__init__.py

示例10: load_dialect_impl

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import CHAR [as 别名]
def load_dialect_impl(self, dialect):
        if dialect.name == "postgresql":
            return dialect.type_descriptor(UUID())

        else:
            return dialect.type_descriptor(CHAR(32)) 
开发者ID:getsentry,项目名称:zeus,代码行数:8,代码来源:guid.py

示例11: __init__

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import CHAR [as 别名]
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) 
开发者ID:gltn,项目名称:stdm,代码行数:17,代码来源:base.py

示例12: normalize_name

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import CHAR [as 别名]
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 
开发者ID:binhex,项目名称:moviegrabber,代码行数:13,代码来源:base.py

示例13: load_dialect_impl

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import CHAR [as 别名]
def load_dialect_impl(self, dialect):
        if dialect.name == "postgresql":
            return dialect.type_descriptor(UUID())
        else:
            return dialect.type_descriptor(CHAR(36)) 
开发者ID:frankie567,项目名称:fastapi-users,代码行数:7,代码来源:sqlalchemy.py

示例14: _get_column_info

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import CHAR [as 别名]
def _get_column_info(
        self,
        name,
        type_,
        nullable,
        autoincrement,
        default,
        precision,
        scale,
        length,
    ):

        coltype = self.ischema_names.get(type_, None)

        kwargs = {}

        if coltype in (NUMERIC, DECIMAL):
            args = (precision, scale)
        elif coltype == FLOAT:
            args = (precision,)
        elif coltype in (CHAR, VARCHAR, UNICHAR, UNIVARCHAR, NCHAR, NVARCHAR):
            args = (length,)
        else:
            args = ()

        if coltype:
            coltype = coltype(*args, **kwargs)
            # is this necessary
            # if is_array:
            #     coltype = ARRAY(coltype)
        else:
            util.warn(
                "Did not recognize type '%s' of column '%s'" % (type_, name)
            )
            coltype = sqltypes.NULLTYPE

        if default:
            default = default.replace("DEFAULT", "").strip()
            default = re.sub("^'(.*)'$", lambda m: m.group(1), default)
        else:
            default = None

        column_info = dict(
            name=name,
            type=coltype,
            nullable=nullable,
            default=default,
            autoincrement=autoincrement,
        )
        return column_info 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:52,代码来源:base.py

示例15: _fixed_lookup_fixture

# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import CHAR [as 别名]
def _fixed_lookup_fixture(self):
        return [
            (sqltypes.String(), sqltypes.VARCHAR()),
            (sqltypes.String(1), sqltypes.VARCHAR(1)),
            (sqltypes.String(3), sqltypes.VARCHAR(3)),
            (sqltypes.Text(), sqltypes.TEXT()),
            (sqltypes.Unicode(), sqltypes.VARCHAR()),
            (sqltypes.Unicode(1), sqltypes.VARCHAR(1)),
            (sqltypes.UnicodeText(), sqltypes.TEXT()),
            (sqltypes.CHAR(3), sqltypes.CHAR(3)),
            (sqltypes.NUMERIC, sqltypes.NUMERIC()),
            (sqltypes.NUMERIC(10, 2), sqltypes.NUMERIC(10, 2)),
            (sqltypes.Numeric, sqltypes.NUMERIC()),
            (sqltypes.Numeric(10, 2), sqltypes.NUMERIC(10, 2)),
            (sqltypes.DECIMAL, sqltypes.DECIMAL()),
            (sqltypes.DECIMAL(10, 2), sqltypes.DECIMAL(10, 2)),
            (sqltypes.INTEGER, sqltypes.INTEGER()),
            (sqltypes.BIGINT, sqltypes.BIGINT()),
            (sqltypes.Float, sqltypes.FLOAT()),
            (sqltypes.TIMESTAMP, sqltypes.TIMESTAMP()),
            (sqltypes.DATETIME, sqltypes.DATETIME()),
            (sqltypes.DateTime, sqltypes.DATETIME()),
            (sqltypes.DateTime(), sqltypes.DATETIME()),
            (sqltypes.DATE, sqltypes.DATE()),
            (sqltypes.Date, sqltypes.DATE()),
            (sqltypes.TIME, sqltypes.TIME()),
            (sqltypes.Time, sqltypes.TIME()),
            (sqltypes.BOOLEAN, sqltypes.BOOLEAN()),
            (sqltypes.Boolean, sqltypes.BOOLEAN()),
            (
                sqlite.DATE(storage_format="%(year)04d%(month)02d%(day)02d"),
                sqltypes.DATE(),
            ),
            (
                sqlite.TIME(
                    storage_format="%(hour)02d%(minute)02d%(second)02d"
                ),
                sqltypes.TIME(),
            ),
            (
                sqlite.DATETIME(
                    storage_format="%(year)04d%(month)02d%(day)02d"
                    "%(hour)02d%(minute)02d%(second)02d"
                ),
                sqltypes.DATETIME(),
            ),
        ] 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:49,代码来源:test_sqlite.py


注:本文中的sqlalchemy.types.CHAR属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。