當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。