本文整理汇总了Python中sqlalchemy.util.b函数的典型用法代码示例。如果您正苦于以下问题:Python b函数的具体用法?Python b怎么用?Python b使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了b函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_raw_roundtrip
def test_raw_roundtrip(self):
metadata = self.metadata
raw_table = Table('raw', metadata,
Column('id', Integer, primary_key=True),
Column('data', oracle.RAW(35)))
metadata.create_all()
testing.db.execute(raw_table.insert(), id=1, data=b("ABCDEF"))
eq_(
testing.db.execute(raw_table.select()).first(),
(1, b("ABCDEF"))
)
开发者ID:eoghanmurray,项目名称:sqlalchemy,代码行数:11,代码来源:test_types.py
示例2: test_nonunicode_default
def test_nonunicode_default(self):
default = b('foo')
assert_raises_message(
sa.exc.SAWarning,
"Unicode column received non-unicode default value.",
Column,
Unicode(32),
default=default
)
开发者ID:Affirm,项目名称:sqlalchemy,代码行数:9,代码来源:test_defaults.py
示例3: test_nonunicode_default
def test_nonunicode_default(self):
default = b('foo')
assert_raises_message(
sa.exc.SAWarning,
"Unicode column 'foobar' has non-unicode "
"default value b?'foo' specified.",
Column,
"foobar", Unicode(32),
default=default
)
开发者ID:NaiRobley,项目名称:sqlalchemy,代码行数:10,代码来源:test_defaults.py
示例4: test_unicode_warnings_dialectlevel
def test_unicode_warnings_dialectlevel(self):
unicodedata = self.data
with testing.expect_deprecated(
"The create_engine.convert_unicode parameter and "
"corresponding dialect-level"
):
dialect = default.DefaultDialect(convert_unicode=True)
dialect.supports_unicode_binds = False
s = String()
uni = s.dialect_impl(dialect).bind_processor(dialect)
uni(util.b("x"))
assert isinstance(uni(unicodedata), util.binary_type)
eq_(uni(unicodedata), unicodedata.encode("utf-8"))
开发者ID:BY-jk,项目名称:sqlalchemy,代码行数:18,代码来源:test_deprecations.py
示例5: insert_data
def insert_data(cls):
cls.data = data = [
dict(
id=i, data='this is text %d' % i,
bindata=b('this is binary %d' % i)
) for i in range(1, 20)
]
testing.db.execute(cls.tables.z_test.insert(), data)
binary_table = cls.tables.binary_table
fname = os.path.join(
os.path.dirname(__file__), "..", "..",
'binary_data_one.dat')
with open(fname, "rb") as file_:
cls.stream = stream = file_.read(12000)
for i in range(1, 11):
binary_table.insert().execute(id=i, data=stream)
开发者ID:eoghanmurray,项目名称:sqlalchemy,代码行数:19,代码来源:test_types.py
示例6: test_bytes
def test_bytes(self):
module = __import__('pymssql')
input = b('\x80\x03]q\x00X\x03\x00\x00\x00oneq\x01a.')
expected_result = input
result = module.Binary(input)
eq_(result, expected_result)
开发者ID:MyExperience,项目名称:HealAssist,代码行数:6,代码来源:test_types.py
示例7: test_lobs_with_convert_raw
def test_lobs_with_convert_raw(self):
row = testing.db.execute("select data, bindata from z_test").first()
eq_(row['data'], 'this is text 1')
eq_(row['bindata'], b('this is binary 1'))
开发者ID:eoghanmurray,项目名称:sqlalchemy,代码行数:4,代码来源:test_types.py
示例8: test_lobs_with_convert
def test_lobs_with_convert(self):
t = self.tables.z_test
row = testing.db.execute(t.select().where(t.c.id == 1)).first()
eq_(row['data'], 'this is text 1')
eq_(row['bindata'], b('this is binary 1'))
开发者ID:eoghanmurray,项目名称:sqlalchemy,代码行数:5,代码来源:test_types.py
示例9: test_lobs_without_convert
def test_lobs_without_convert(self):
engine = testing_engine(options=dict(auto_convert_lobs=False))
t = self.tables.z_test
row = engine.execute(t.select().where(t.c.id == 1)).first()
eq_(row['data'].read(), 'this is text 1')
eq_(row['bindata'].read(), b('this is binary 1'))
开发者ID:eoghanmurray,项目名称:sqlalchemy,代码行数:6,代码来源:test_types.py
示例10: test_character_binary
def test_character_binary(self):
self._test_round_trip(mssql.MSVarBinary(800), b("some normal data"))
开发者ID:vrajmohan,项目名称:sqlalchemy,代码行数:2,代码来源:test_types.py
注:本文中的sqlalchemy.util.b函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论