本文整理汇总了Python中sqlalchemy.sql.table.schema方法的典型用法代码示例。如果您正苦于以下问题:Python table.schema方法的具体用法?Python table.schema怎么用?Python table.schema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sqlalchemy.sql.table
的用法示例。
在下文中一共展示了table.schema方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: from_constraint
# 需要导入模块: from sqlalchemy.sql import table [as 别名]
# 或者: from sqlalchemy.sql.table import schema [as 别名]
def from_constraint(cls, constraint):
types = {
"unique_constraint": "unique",
"foreign_key_constraint": "foreignkey",
"primary_key_constraint": "primary",
"check_constraint": "check",
"column_check_constraint": "check",
}
constraint_table = sqla_compat._table_for_constraint(constraint)
return cls(
constraint.name,
constraint_table.name,
schema=constraint_table.schema,
type_=types[constraint.__visit_name__],
_orig_constraint=constraint
)
示例2: batch_drop_constraint
# 需要导入模块: from sqlalchemy.sql import table [as 别名]
# 或者: from sqlalchemy.sql.table import schema [as 别名]
def batch_drop_constraint(cls, operations, constraint_name, type_=None):
"""Issue a "drop constraint" instruction using the
current batch migration context.
The batch form of this call omits the ``table_name`` and ``schema``
arguments from the call.
.. seealso::
:meth:`.Operations.drop_constraint`
.. versionchanged:: 0.8.0 The following positional argument names
have been changed:
* name -> constraint_name
"""
op = cls(
constraint_name, operations.impl.table_name,
type_=type_, schema=operations.impl.schema
)
return operations.invoke(op)
示例3: batch_create_primary_key
# 需要导入模块: from sqlalchemy.sql import table [as 别名]
# 或者: from sqlalchemy.sql.table import schema [as 别名]
def batch_create_primary_key(cls, operations, constraint_name, columns):
"""Issue a "create primary key" instruction using the
current batch migration context.
The batch form of this call omits the ``table_name`` and ``schema``
arguments from the call.
.. seealso::
:meth:`.Operations.create_primary_key`
"""
op = cls(
constraint_name, operations.impl.table_name, columns,
schema=operations.impl.schema
)
return operations.invoke(op)
示例4: batch_create_unique_constraint
# 需要导入模块: from sqlalchemy.sql import table [as 别名]
# 或者: from sqlalchemy.sql.table import schema [as 别名]
def batch_create_unique_constraint(
cls, operations, constraint_name, columns, **kw):
"""Issue a "create unique constraint" instruction using the
current batch migration context.
The batch form of this call omits the ``source`` and ``schema``
arguments from the call.
.. seealso::
:meth:`.Operations.create_unique_constraint`
.. versionchanged:: 0.8.0 The following positional argument names
have been changed:
* name -> constraint_name
"""
kw['schema'] = operations.impl.schema
op = cls(
constraint_name, operations.impl.table_name, columns,
**kw
)
return operations.invoke(op)
示例5: batch_create_check_constraint
# 需要导入模块: from sqlalchemy.sql import table [as 别名]
# 或者: from sqlalchemy.sql.table import schema [as 别名]
def batch_create_check_constraint(
cls, operations, constraint_name, condition, **kw):
"""Issue a "create check constraint" instruction using the
current batch migration context.
The batch form of this call omits the ``source`` and ``schema``
arguments from the call.
.. seealso::
:meth:`.Operations.create_check_constraint`
.. versionchanged:: 0.8.0 The following positional argument names
have been changed:
* name -> constraint_name
"""
op = cls(
constraint_name, operations.impl.table_name,
condition, schema=operations.impl.schema, **kw)
return operations.invoke(op)
示例6: batch_drop_index
# 需要导入模块: from sqlalchemy.sql import table [as 别名]
# 或者: from sqlalchemy.sql.table import schema [as 别名]
def batch_drop_index(cls, operations, index_name, **kw):
"""Issue a "drop index" instruction using the
current batch migration context.
.. seealso::
:meth:`.Operations.drop_index`
.. versionchanged:: 0.8.0 The following positional argument names
have been changed:
* name -> index_name
"""
op = cls(
index_name, table_name=operations.impl.table_name,
schema=operations.impl.schema
)
return operations.invoke(op)
示例7: rename_table
# 需要导入模块: from sqlalchemy.sql import table [as 别名]
# 或者: from sqlalchemy.sql.table import schema [as 别名]
def rename_table(
cls, operations, old_table_name, new_table_name, schema=None):
"""Emit an ALTER TABLE to rename a table.
:param old_table_name: old name.
:param new_table_name: new name.
:param schema: Optional schema name to operate within. To control
quoting of the schema outside of the default behavior, use
the SQLAlchemy construct
:class:`~sqlalchemy.sql.elements.quoted_name`.
.. versionadded:: 0.7.0 'schema' can now accept a
:class:`~sqlalchemy.sql.elements.quoted_name` construct.
"""
op = cls(old_table_name, new_table_name, schema=schema)
return operations.invoke(op)
示例8: __init__
# 需要导入模块: from sqlalchemy.sql import table [as 别名]
# 或者: from sqlalchemy.sql.table import schema [as 别名]
def __init__(
self, table_name, column_name, schema=None,
existing_type=None,
existing_server_default=False,
existing_nullable=None,
modify_nullable=None,
modify_server_default=False,
modify_name=None,
modify_type=None,
**kw
):
super(AlterColumnOp, self).__init__(table_name, schema=schema)
self.column_name = column_name
self.existing_type = existing_type
self.existing_server_default = existing_server_default
self.existing_nullable = existing_nullable
self.modify_nullable = modify_nullable
self.modify_server_default = modify_server_default
self.modify_name = modify_name
self.modify_type = modify_type
self.kw = kw
示例9: drop_constraint
# 需要导入模块: from sqlalchemy.sql import table [as 别名]
# 或者: from sqlalchemy.sql.table import schema [as 别名]
def drop_constraint(
cls, operations, constraint_name, table_name,
type_=None, schema=None):
"""Drop a constraint of the given name, typically via DROP CONSTRAINT.
:param constraint_name: name of the constraint.
:param table_name: table name.
:param type_: optional, required on MySQL. can be
'foreignkey', 'primary', 'unique', or 'check'.
:param schema: Optional schema name to operate within. To control
quoting of the schema outside of the default behavior, use
the SQLAlchemy construct
:class:`~sqlalchemy.sql.elements.quoted_name`.
.. versionadded:: 0.7.0 'schema' can now accept a
:class:`~sqlalchemy.sql.elements.quoted_name` construct.
.. versionchanged:: 0.8.0 The following positional argument names
have been changed:
* name -> constraint_name
"""
op = cls(constraint_name, table_name, type_=type_, schema=schema)
return operations.invoke(op)
示例10: to_constraint
# 需要导入模块: from sqlalchemy.sql import table [as 别名]
# 或者: from sqlalchemy.sql.table import schema [as 别名]
def to_constraint(self, migration_context=None):
if self._orig_constraint is not None:
return self._orig_constraint
schema_obj = schemaobj.SchemaObjects(migration_context)
return schema_obj.primary_key_constraint(
self.constraint_name, self.table_name,
self.columns, schema=self.schema)
示例11: from_index
# 需要导入模块: from sqlalchemy.sql import table [as 别名]
# 或者: from sqlalchemy.sql.table import schema [as 别名]
def from_index(cls, index):
return cls(
index.name,
index.table.name,
sqla_compat._get_index_expressions(index),
schema=index.table.schema,
unique=index.unique,
_orig_index=index,
**index.kwargs
)
示例12: to_index
# 需要导入模块: from sqlalchemy.sql import table [as 别名]
# 或者: from sqlalchemy.sql.table import schema [as 别名]
def to_index(self, migration_context=None):
if self._orig_index:
return self._orig_index
schema_obj = schemaobj.SchemaObjects(migration_context)
return schema_obj.index(
self.index_name, self.table_name, self.columns, schema=self.schema,
unique=self.unique, **self.kw)
示例13: drop_index
# 需要导入模块: from sqlalchemy.sql import table [as 别名]
# 或者: from sqlalchemy.sql.table import schema [as 别名]
def drop_index(cls, operations, index_name, table_name=None, schema=None):
"""Issue a "drop index" instruction using the current
migration context.
e.g.::
drop_index("accounts")
:param index_name: name of the index.
:param table_name: name of the owning table. Some
backends such as Microsoft SQL Server require this.
:param schema: Optional schema name to operate within. To control
quoting of the schema outside of the default behavior, use
the SQLAlchemy construct
:class:`~sqlalchemy.sql.elements.quoted_name`.
.. versionadded:: 0.7.0 'schema' can now accept a
:class:`~sqlalchemy.sql.elements.quoted_name` construct.
.. versionchanged:: 0.8.0 The following positional argument names
have been changed:
* name -> index_name
"""
op = cls(index_name, table_name=table_name, schema=schema)
return operations.invoke(op)