本文整理匯總了Python中sqlalchemy.types.UnicodeText方法的典型用法代碼示例。如果您正苦於以下問題:Python types.UnicodeText方法的具體用法?Python types.UnicodeText怎麽用?Python types.UnicodeText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sqlalchemy.types
的用法示例。
在下文中一共展示了types.UnicodeText方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: define_showcase_package_association_table
# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import UnicodeText [as 別名]
def define_showcase_package_association_table():
global showcase_package_assocation_table
showcase_package_assocation_table = Table(
'showcase_package_association', metadata,
Column('package_id', types.UnicodeText,
ForeignKey('package.id',
ondelete='CASCADE',
onupdate='CASCADE'),
primary_key=True, nullable=False),
Column('showcase_id', types.UnicodeText,
ForeignKey('package.id',
ondelete='CASCADE',
onupdate='CASCADE'),
primary_key=True, nullable=False)
)
mapper(ShowcasePackageAssociation, showcase_package_assocation_table)
示例2: test_no_convert_unicode
# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import UnicodeText [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
)
示例3: test_mssql_column_types
# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import UnicodeText [as 別名]
def test_mssql_column_types(self):
def assert_type(type_string, type_expected):
type_assigned = MssqlEngineSpec.get_sqla_column_type(type_string)
if type_expected is None:
self.assertIsNone(type_assigned)
else:
self.assertIsInstance(type_assigned, type_expected)
assert_type("INT", None)
assert_type("STRING", String)
assert_type("CHAR(10)", String)
assert_type("VARCHAR(10)", String)
assert_type("TEXT", String)
assert_type("NCHAR(10)", UnicodeText)
assert_type("NVARCHAR(10)", UnicodeText)
assert_type("NTEXT", UnicodeText)
示例4: result_processor
# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import UnicodeText [as 別名]
def result_processor(self, dialect, coltype):
lob_processor = _LOBMixin.result_processor(self, dialect, coltype)
if lob_processor is None:
return None
string_processor = sqltypes.UnicodeText.result_processor(
self, dialect, coltype)
if string_processor is None:
return lob_processor
else:
def process(value):
return string_processor(lob_processor(value))
return process
示例5: setup_spatial_table
# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import UnicodeText [as 別名]
def setup_spatial_table(package_extent_class, db_srid=None):
if legacy_geoalchemy:
package_extent_table = Table(
'package_extent', meta.metadata,
Column('package_id', types.UnicodeText, primary_key=True),
GeometryExtensionColumn('the_geom', Geometry(2, srid=db_srid))
)
meta.mapper(
package_extent_class,
package_extent_table,
properties={'the_geom':
GeometryColumn(package_extent_table.c.the_geom,
comparator=PGComparator)}
)
GeometryDDL(package_extent_table)
else:
# PostGIS 1.5 requires management=True when defining the Geometry
# field
management = (postgis_version()[:1] == '1')
package_extent_table = Table(
'package_extent', meta.metadata,
Column('package_id', types.UnicodeText, primary_key=True),
Column('the_geom', Geometry('GEOMETRY', srid=db_srid,
management=management)),
)
meta.mapper(package_extent_class, package_extent_table)
return package_extent_table
示例6: upgrade
# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import UnicodeText [as 別名]
def upgrade(migrate_engine):
metadata = MetaData()
metadata.bind = migrate_engine
group_table = Table('group', metadata, autoload=True)
group_extra_table = Table('group_extra', metadata,
Column('id', UnicodeText, primary_key=True, default=make_uuid),
Column('group_id', UnicodeText, ForeignKey('group.id')),
Column('key', UnicodeText),
Column('value', JsonType),
)
group_extra_table.create()
示例7: test_should_unicodetext_convert_string
# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import UnicodeText [as 別名]
def test_should_unicodetext_convert_string():
assert get_field(types.UnicodeText()).type == graphene.String
示例8: define_showcase_admin_table
# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import UnicodeText [as 別名]
def define_showcase_admin_table():
global showcase_admin_table
showcase_admin_table = Table('showcase_admin', metadata,
Column('user_id', types.UnicodeText,
ForeignKey('user.id',
ondelete='CASCADE',
onupdate='CASCADE'),
primary_key=True, nullable=False))
mapper(ShowcaseAdmin, showcase_admin_table)
示例9: result_processor
# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import UnicodeText [as 別名]
def result_processor(self, dialect, coltype):
lob_processor = _LOBMixin.result_processor(self, dialect, coltype)
if lob_processor is None:
return None
string_processor = sqltypes.UnicodeText.result_processor(self, dialect, coltype)
if string_processor is None:
return lob_processor
else:
def process(value):
return string_processor(lob_processor(value))
return process
示例10: _fixed_lookup_fixture
# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import UnicodeText [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(),
),
]
示例11: setup
# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import UnicodeText [as 別名]
def setup():
"""
Set up ORM.
Does not create any database tables, see :py:func:`create_tables`
for that.
"""
global resource_metadata_table
if resource_metadata_table is None:
log.debug('Defining resource metadata table')
resource_metadata_table = Table(
RESOURCE_METADATA_TABLE_NAME,
metadata,
Column('resource_id', types.UnicodeText, ForeignKey('resource.id',
ondelete='CASCADE', onupdate='CASCADE'), nullable=False,
primary_key=True),
Column('last_extracted', types.DateTime),
Column('last_url', types.UnicodeText),
Column('last_format', types.UnicodeText),
Column('task_id', types.UnicodeText)
)
mapper(
ResourceMetadata,
resource_metadata_table,
properties={
'_meta': relationship(ResourceMetadatum, collection_class=
attribute_mapped_collection('key'),
cascade='all, delete, delete-orphan'),
}
)
else:
log.debug('Resource metadata table already defined')
global resource_metadatum_table
if resource_metadatum_table is None:
log.debug('Defining resource metadatum table')
resource_metadatum_table = Table(
RESOURCE_METADATUM_TABLE_NAME,
metadata,
Column('id', types.Integer, nullable=False, primary_key=True),
Column('resource_id', types.UnicodeText, ForeignKey(
RESOURCE_METADATA_TABLE_NAME + '.resource_id',
ondelete='CASCADE', onupdate='CASCADE'), nullable=False),
Column('key', types.UnicodeText, nullable=False),
Column('value', types.UnicodeText)
)
mapper(ResourceMetadatum, resource_metadatum_table)
else:
log.debug('Resource metadatum table already defined')