本文整理汇总了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
)
示例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)
示例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
示例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))
示例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))
示例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))
示例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))
示例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
示例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
示例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))
示例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)
示例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
示例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))
示例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
示例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(),
),
]