本文整理汇总了Python中sqlalchemy.UnicodeText方法的典型用法代码示例。如果您正苦于以下问题:Python sqlalchemy.UnicodeText方法的具体用法?Python sqlalchemy.UnicodeText怎么用?Python sqlalchemy.UnicodeText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sqlalchemy
的用法示例。
在下文中一共展示了sqlalchemy.UnicodeText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import UnicodeText [as 别名]
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('category_group',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.Unicode(length=100), nullable=False),
sa.Column('description', sa.UnicodeText(), nullable=True),
sa.Column('grouporder', sa.Float(), nullable=False),
sa.Column('date_created', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name')
)
op.create_table('population_group',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.Unicode(length=100), nullable=False),
sa.Column('description', sa.UnicodeText(), nullable=True),
sa.Column('grouporder', sa.Float(), nullable=False),
sa.Column('date_created', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name')
)
op.add_column(u'category', sa.Column('grouping_id', sa.Integer(), nullable=True))
op.add_column(u'population', sa.Column('grouping_id', sa.Integer(), nullable=True))
### end Alembic commands ###
示例2: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import UnicodeText [as 别名]
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('URL',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('url', sa.UnicodeText(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('url')
)
op.create_table('file',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('sha256', sa.String(), nullable=True),
sa.Column('ext', sa.UnicodeText(), nullable=True),
sa.Column('mime', sa.UnicodeText(), nullable=True),
sa.Column('addr', sa.UnicodeText(), nullable=True),
sa.Column('removed', sa.Boolean(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('sha256')
)
### end Alembic commands ###
示例3: _init_jobs_table
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import UnicodeText [as 别名]
def _init_jobs_table():
"""Initialise the "jobs" table in the db."""
_jobs_table = sqlalchemy.Table(
'jobs', _METADATA,
sqlalchemy.Column('job_id', sqlalchemy.UnicodeText, primary_key=True),
sqlalchemy.Column('job_type', sqlalchemy.UnicodeText),
sqlalchemy.Column('status', sqlalchemy.UnicodeText, index=True),
sqlalchemy.Column('data', sqlalchemy.UnicodeText),
sqlalchemy.Column('error', sqlalchemy.UnicodeText),
sqlalchemy.Column('requested_timestamp', sqlalchemy.DateTime),
sqlalchemy.Column('finished_timestamp', sqlalchemy.DateTime),
sqlalchemy.Column('sent_data', sqlalchemy.UnicodeText),
# Callback URL:
sqlalchemy.Column('result_url', sqlalchemy.UnicodeText),
# CKAN API key:
sqlalchemy.Column('api_key', sqlalchemy.UnicodeText),
)
return _jobs_table
示例4: test_ora8_flags
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import UnicodeText [as 别名]
def test_ora8_flags(self):
dialect = self._dialect((8, 2, 5))
# before connect, assume modern DB
assert dialect._supports_char_length
assert dialect.use_ansi
assert not dialect._use_nchar_for_unicode
dialect.initialize(Mock())
assert not dialect.implicit_returning
assert not dialect._supports_char_length
assert not dialect.use_ansi
self.assert_compile(String(50), "VARCHAR2(50)", dialect=dialect)
self.assert_compile(Unicode(50), "VARCHAR2(50)", dialect=dialect)
self.assert_compile(UnicodeText(), "CLOB", dialect=dialect)
dialect = self._dialect((8, 2, 5), implicit_returning=True)
dialect.initialize(testing.db.connect())
assert dialect.implicit_returning
示例5: test_large_type_deprecation
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import UnicodeText [as 别名]
def test_large_type_deprecation(self):
d1 = mssql.dialect(deprecate_large_types=True)
d2 = mssql.dialect(deprecate_large_types=False)
d3 = mssql.dialect()
d3.server_version_info = (11, 0)
d3._setup_version_attributes()
d4 = mssql.dialect()
d4.server_version_info = (10, 0)
d4._setup_version_attributes()
for dialect in (d1, d3):
eq_(str(Text().compile(dialect=dialect)), "VARCHAR(max)")
eq_(str(UnicodeText().compile(dialect=dialect)), "NVARCHAR(max)")
eq_(str(LargeBinary().compile(dialect=dialect)), "VARBINARY(max)")
for dialect in (d2, d4):
eq_(str(Text().compile(dialect=dialect)), "TEXT")
eq_(str(UnicodeText().compile(dialect=dialect)), "NTEXT")
eq_(str(LargeBinary().compile(dialect=dialect)), "IMAGE")
示例6: test_charset_collate_table
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import UnicodeText [as 别名]
def test_charset_collate_table(self):
t = Table(
"foo",
self.metadata,
Column("id", Integer),
Column("data", UnicodeText),
mysql_default_charset="utf8",
mysql_collate="utf8_bin",
)
t.create()
m2 = MetaData(testing.db)
t2 = Table("foo", m2, autoload=True)
eq_(t2.kwargs["mysql_collate"], "utf8_bin")
eq_(t2.kwargs["mysql_default charset"], "utf8")
# test [ticket:2906]
# in order to test the condition here, need to use
# MySQLdb 1.2.3 and also need to pass either use_unicode=1
# or charset=utf8 to the URL.
t.insert().execute(id=1, data=u("some text"))
assert isinstance(
testing.db.scalar(select([t.c.data])), util.text_type
)
示例7: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import UnicodeText [as 别名]
def upgrade():
try:
op.create_table('smsgateway',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('identifier', sa.Unicode(length=255), nullable=False),
sa.Column('description', sa.Unicode(length=1024), nullable=True),
sa.Column('providermodule', sa.Unicode(length=1024), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('identifier')
)
op.create_table('smsgatewayoption',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('Key', sa.Unicode(length=255), nullable=False),
sa.Column('Value', sa.UnicodeText(), nullable=True),
sa.Column('Type', sa.Unicode(length=100), nullable=True),
sa.Column('gateway_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['gateway_id'], ['smsgateway.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('gateway_id', 'Key', name='sgix_1')
)
op.create_index(op.f('ix_smsgatewayoption_gateway_id'), 'smsgatewayoption', ['gateway_id'], unique=False)
except (OperationalError, ProgrammingError, InternalError) as exx:
if "duplicate column name" in str(exx.orig).lower():
print("Good. Table smsgateway already exists.")
else:
print("Table already exists")
print(exx)
except Exception as exx:
print("Could not add Table smsgateway")
print (exx)
### end Alembic commands ###
示例8: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import UnicodeText [as 别名]
def upgrade():
"""Create DagCode Table."""
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class SerializedDagModel(Base):
__tablename__ = 'serialized_dag'
# There are other columns here, but these are the only ones we need for the SELECT/UPDATE we are doing
dag_id = sa.Column(sa.String(250), primary_key=True)
fileloc = sa.Column(sa.String(2000), nullable=False)
fileloc_hash = sa.Column(sa.BigInteger, nullable=False)
"""Apply add source code table"""
op.create_table('dag_code', # pylint: disable=no-member
sa.Column('fileloc_hash', sa.BigInteger(),
nullable=False, primary_key=True, autoincrement=False),
sa.Column('fileloc', sa.String(length=2000), nullable=False),
sa.Column('source_code', sa.UnicodeText(), nullable=False),
sa.Column('last_updated', sa.TIMESTAMP(timezone=True), nullable=False))
conn = op.get_bind()
if conn.dialect.name not in ('sqlite'):
if conn.dialect.name == "mssql":
op.drop_index('idx_fileloc_hash', 'serialized_dag')
op.alter_column(table_name='serialized_dag', column_name='fileloc_hash',
type_=sa.BigInteger(), nullable=False)
if conn.dialect.name == "mssql":
op.create_index('idx_fileloc_hash', 'serialized_dag', ['fileloc_hash'])
sessionmaker = sa.orm.sessionmaker()
session = sessionmaker(bind=conn)
serialized_dags = session.query(SerializedDagModel).all()
for dag in serialized_dags:
dag.fileloc_hash = DagCode.dag_fileloc_hash(dag.fileloc)
session.merge(dag)
session.commit()
示例9: downgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import UnicodeText [as 别名]
def downgrade():
op.add_column('card', sa.Column('description', sa.UnicodeText, default=u''))
op.drop_table('card_description')
op.add_column('card', sa.Column('due_date', sa.Date))
op.drop_table('card_due_date')
op.add_column('card', sa.Column('weight', sa.Unicode(255)))
op.drop_table('card_weight')
示例10: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import UnicodeText [as 别名]
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('resource', sa.Column('notes', sa.UnicodeText(), nullable=True))
### end Alembic commands ###
示例11: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import UnicodeText [as 别名]
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('category', sa.Column('keywords', sa.UnicodeText(), nullable=True))
### end Alembic commands ###
示例12: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import UnicodeText [as 别名]
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('resource', sa.Column('advisory_notes', sa.UnicodeText(), nullable=True))
### end Alembic commands ###
示例13: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import UnicodeText [as 别名]
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('population',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.Unicode(length=100), nullable=False),
sa.Column('description', sa.UnicodeText(), nullable=True),
sa.Column('keywords', sa.UnicodeText(), nullable=True),
sa.Column('visible', sa.Boolean(), nullable=False),
sa.Column('date_created', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name')
)
### end Alembic commands ###
示例14: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import UnicodeText [as 别名]
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('resource', sa.Column('hours', sa.UnicodeText(), nullable=True))
op.add_column('resource', sa.Column('npi', sa.Unicode(length=10), nullable=True))
### end Alembic commands ###
示例15: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import UnicodeText [as 别名]
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('resource', sa.Column('has_sliding_scale', sa.Boolean(), nullable=True))
op.add_column('resource', sa.Column('hospital_affiliation', sa.UnicodeText(), nullable=True))
op.add_column('resource', sa.Column('is_accessible', sa.Boolean(), nullable=True))
op.add_column('resource', sa.Column('is_icath', sa.Boolean(), nullable=True))
op.add_column('resource', sa.Column('is_wpath', sa.Boolean(), nullable=True))
### end Alembic commands ###