code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def toml_alembic_config(self) -> Mapping[str, Any]: """Return a dictionary of the [tool.alembic] section from pyproject.toml""" if self._toml_file_path and self._toml_file_path.exists(): here = self._toml_file_path.absolute().parent self.toml_args["here"] = here.as_posi...
Return a dictionary of the [tool.alembic] section from pyproject.toml
toml_alembic_config
python
sqlalchemy/alembic
alembic/config.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/config.py
MIT
def get_template_directory(self) -> str: """Return the directory where Alembic setup templates are found. This method is used by the alembic ``init`` and ``list_templates`` commands. """ import alembic package_dir = Path(alembic.__file__).absolute().parent retu...
Return the directory where Alembic setup templates are found. This method is used by the alembic ``init`` and ``list_templates`` commands.
get_template_directory
python
sqlalchemy/alembic
alembic/config.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/config.py
MIT
def get_section( self, name: str, default: Optional[Mapping[str, str]] = None ) -> Optional[Mapping[str, str]]: """Return all the configuration options from a given .ini file section as a dictionary. If the given section does not exist, the value of ``default`` is returned, ...
Return all the configuration options from a given .ini file section as a dictionary. If the given section does not exist, the value of ``default`` is returned, which is expected to be a dictionary or other mapping.
get_section
python
sqlalchemy/alembic
alembic/config.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/config.py
MIT
def set_section_option(self, section: str, name: str, value: str) -> None: """Set an option programmatically within the given section. The section is created if it doesn't exist already. The value here will override whatever was in the .ini file. Does **NOT** consume from the p...
Set an option programmatically within the given section. The section is created if it doesn't exist already. The value here will override whatever was in the .ini file. Does **NOT** consume from the pyproject.toml file. .. seealso:: :meth:`.Config.get_alembic_opti...
set_section_option
python
sqlalchemy/alembic
alembic/config.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/config.py
MIT
def get_section_option( self, section: str, name: str, default: Optional[str] = None ) -> Optional[str]: """Return an option from the given section of the .ini file.""" if not self.file_config.has_section(section): raise util.CommandError( "No config file %r found...
Return an option from the given section of the .ini file.
get_section_option
python
sqlalchemy/alembic
alembic/config.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/config.py
MIT
def get_main_option( self, name: str, default: Optional[str] = None ) -> Optional[str]: """Return an option from the 'main' section of the .ini file. This defaults to being a key from the ``[alembic]`` section, unless the ``-n/--name`` flag were used to indicate a different ...
Return an option from the 'main' section of the .ini file. This defaults to being a key from the ``[alembic]`` section, unless the ``-n/--name`` flag were used to indicate a different section. Does **NOT** consume from the pyproject.toml file. .. seealso:: :meth:`...
get_main_option
python
sqlalchemy/alembic
alembic/config.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/config.py
MIT
def get_alembic_option( self, name: str, default: Optional[str] = None ) -> Union[None, str, list[str], dict[str, str], list[dict[str, str]]]: """Return an option from the "[alembic]" or "[tool.alembic]" section of the configparser-parsed .ini file (e.g. ``alembic.ini``) or toml-pars...
Return an option from the "[alembic]" or "[tool.alembic]" section of the configparser-parsed .ini file (e.g. ``alembic.ini``) or toml-parsed ``pyproject.toml`` file. The value returned is expected to be None, string, list of strings, or dictionary of strings. Within each type of strin...
get_alembic_option
python
sqlalchemy/alembic
alembic/config.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/config.py
MIT
def register_command(self, fn: CommandFunction) -> None: """Registers a function as a CLI subcommand. The subcommand name matches the function name, the arguments are extracted from the signature and the help text is read from the docstring. .. versionadded:: 1.15.3 .. seealso:...
Registers a function as a CLI subcommand. The subcommand name matches the function name, the arguments are extracted from the signature and the help text is read from the docstring. .. versionadded:: 1.15.3 .. seealso:: :ref:`custom_commandline`
register_command
python
sqlalchemy/alembic
alembic/config.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/config.py
MIT
def main(self, argv: Optional[Sequence[str]] = None) -> None: """Executes the command line with the provided arguments.""" options = self.parser.parse_args(argv) if not hasattr(options, "cmd"): # see http://bugs.python.org/issue9253, argparse # behavior changed incompatib...
Executes the command line with the provided arguments.
main
python
sqlalchemy/alembic
alembic/config.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/config.py
MIT
def main( argv: Optional[Sequence[str]] = None, prog: Optional[str] = None, **kwargs: Any, ) -> None: """The console runner function for Alembic.""" CommandLine(prog=prog).main(argv=argv)
The console runner function for Alembic.
main
python
sqlalchemy/alembic
alembic/config.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/config.py
MIT
def compare_metadata(context: MigrationContext, metadata: MetaData) -> Any: """Compare a database schema to that given in a :class:`~sqlalchemy.schema.MetaData` instance. The database connection is presented in the context of a :class:`.MigrationContext` object, which provides database connectivity...
Compare a database schema to that given in a :class:`~sqlalchemy.schema.MetaData` instance. The database connection is presented in the context of a :class:`.MigrationContext` object, which provides database connectivity as well as optional comparison functions to use for datatypes and server d...
compare_metadata
python
sqlalchemy/alembic
alembic/autogenerate/api.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/autogenerate/api.py
MIT
def produce_migrations( context: MigrationContext, metadata: MetaData ) -> MigrationScript: """Produce a :class:`.MigrationScript` structure based on schema comparison. This function does essentially what :func:`.compare_metadata` does, but then runs the resulting list of diffs to produce the full ...
Produce a :class:`.MigrationScript` structure based on schema comparison. This function does essentially what :func:`.compare_metadata` does, but then runs the resulting list of diffs to produce the full :class:`.MigrationScript` object. For an example of what this looks like, see the example in ...
produce_migrations
python
sqlalchemy/alembic
alembic/autogenerate/api.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/autogenerate/api.py
MIT
def render_python_code( up_or_down_op: Union[UpgradeOps, DowngradeOps], sqlalchemy_module_prefix: str = "sa.", alembic_module_prefix: str = "op.", render_as_batch: bool = False, imports: Sequence[str] = (), render_item: Optional[RenderItemFn] = None, migration_context: Optional[MigrationCont...
Render Python code given an :class:`.UpgradeOps` or :class:`.DowngradeOps` object. This is a convenience function that can be used to test the autogenerate output of a user-defined :class:`.MigrationScript` structure. :param up_or_down_op: :class:`.UpgradeOps` or :class:`.DowngradeOps` object :par...
render_python_code
python
sqlalchemy/alembic
alembic/autogenerate/api.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/autogenerate/api.py
MIT
def _render_migration_diffs( context: MigrationContext, template_args: Dict[Any, Any] ) -> None: """legacy, used by test_autogen_composition at the moment""" autogen_context = AutogenContext(context) upgrade_ops = ops.UpgradeOps([]) compare._produce_net_changes(autogen_context, upgrade_ops) m...
legacy, used by test_autogen_composition at the moment
_render_migration_diffs
python
sqlalchemy/alembic
alembic/autogenerate/api.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/autogenerate/api.py
MIT
def run_name_filters( self, name: Optional[str], type_: NameFilterType, parent_names: NameFilterParentNames, ) -> bool: """Run the context's name filters and return True if the targets should be part of the autogenerate operation. This method should be run fo...
Run the context's name filters and return True if the targets should be part of the autogenerate operation. This method should be run for every kind of name encountered within the reflection side of an autogenerate operation, giving the environment the chance to filter what names should...
run_name_filters
python
sqlalchemy/alembic
alembic/autogenerate/api.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/autogenerate/api.py
MIT
def run_object_filters( self, object_: SchemaItem, name: sqla_compat._ConstraintName, type_: NameFilterType, reflected: bool, compare_to: Optional[SchemaItem], ) -> bool: """Run the context's object filters and return True if the targets should be part...
Run the context's object filters and return True if the targets should be part of the autogenerate operation. This method should be run for every kind of object encountered within an autogenerate operation, giving the environment the chance to filter what objects should be included in t...
run_object_filters
python
sqlalchemy/alembic
alembic/autogenerate/api.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/autogenerate/api.py
MIT
def sorted_tables(self) -> List[Table]: """Return an aggregate of the :attr:`.MetaData.sorted_tables` collection(s). For a sequence of :class:`.MetaData` objects, this concatenates the :attr:`.MetaData.sorted_tables` collection for each individual :class:`.MetaData` in the orde...
Return an aggregate of the :attr:`.MetaData.sorted_tables` collection(s). For a sequence of :class:`.MetaData` objects, this concatenates the :attr:`.MetaData.sorted_tables` collection for each individual :class:`.MetaData` in the order of the sequence. It does **not** collate...
sorted_tables
python
sqlalchemy/alembic
alembic/autogenerate/api.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/autogenerate/api.py
MIT
def table_key_to_table(self) -> Dict[str, Table]: """Return an aggregate of the :attr:`.MetaData.tables` dictionaries. The :attr:`.MetaData.tables` collection is a dictionary of table key to :class:`.Table`; this method aggregates the dictionary across multiple :class:`.MetaData` objec...
Return an aggregate of the :attr:`.MetaData.tables` dictionaries. The :attr:`.MetaData.tables` collection is a dictionary of table key to :class:`.Table`; this method aggregates the dictionary across multiple :class:`.MetaData` objects into one dictionary. Duplicate table keys are **n...
table_key_to_table
python
sqlalchemy/alembic
alembic/autogenerate/api.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/autogenerate/api.py
MIT
def _ident(name: Optional[Union[quoted_name, str]]) -> Optional[str]: """produce a __repr__() object for a string identifier that may use quoted_name() in SQLAlchemy 0.9 and greater. The issue worked around here is that quoted_name() doesn't have very good repr() behavior by itself when unicode is invo...
produce a __repr__() object for a string identifier that may use quoted_name() in SQLAlchemy 0.9 and greater. The issue worked around here is that quoted_name() doesn't have very good repr() behavior by itself when unicode is involved.
_ident
python
sqlalchemy/alembic
alembic/autogenerate/render.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/autogenerate/render.py
MIT
def _fk_colspec( fk: ForeignKey, metadata_schema: Optional[str], namespace_metadata: MetaData, ) -> str: """Implement a 'safe' version of ForeignKey._get_colspec() that won't fail if the remote table can't be resolved. """ colspec = fk._get_colspec() tokens = colspec.split(".") tnam...
Implement a 'safe' version of ForeignKey._get_colspec() that won't fail if the remote table can't be resolved.
_fk_colspec
python
sqlalchemy/alembic
alembic/autogenerate/render.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/autogenerate/render.py
MIT
def chain( self, other: Union[ ProcessRevisionDirectiveFn, Rewriter, ], ) -> Rewriter: """Produce a "chain" of this :class:`.Rewriter` to another. This allows two or more rewriters to operate serially on a stream, e.g.:: writer1 =...
Produce a "chain" of this :class:`.Rewriter` to another. This allows two or more rewriters to operate serially on a stream, e.g.:: writer1 = autogenerate.Rewriter() writer2 = autogenerate.Rewriter() @writer1.rewrites(ops.AddColumnOp) def add_column_nul...
chain
python
sqlalchemy/alembic
alembic/autogenerate/rewriter.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/autogenerate/rewriter.py
MIT
def rewrites( self, operator: Union[ Type[AddColumnOp], Type[MigrateOperation], Type[AlterColumnOp], Type[CreateTableOp], Type[ModifyTableOps], ], ) -> Callable[..., Any]: """Register a function as rewriter for a given type....
Register a function as rewriter for a given type. The function should receive three arguments, which are the :class:`.MigrationContext`, a ``revision`` tuple, and an op directive of the type indicated. E.g.:: @writer1.rewrites(ops.AddColumnOp) def add_column_nullable(c...
rewrites
python
sqlalchemy/alembic
alembic/autogenerate/rewriter.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/autogenerate/rewriter.py
MIT
def quote_dotted( name: Union[quoted_name, str], quote: functools.partial ) -> Union[quoted_name, str]: """quote the elements of a dotted name""" if isinstance(name, quoted_name): return quote(name) result = ".".join([quote(x) for x in name.split(".")]) return result
quote the elements of a dotted name
quote_dotted
python
sqlalchemy/alembic
alembic/ddl/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/ddl/base.py
MIT
def version_table_impl( self, *, version_table: str, version_table_schema: Optional[str], version_table_pk: bool, **kw: Any, ) -> Table: """Generate a :class:`.Table` object which will be used as the structure for the Alembic version table. Th...
Generate a :class:`.Table` object which will be used as the structure for the Alembic version table. Third party dialects may override this hook to provide an alternate structure for this :class:`.Table`; requirements are only that it be named based on the ``version_table`` parameter an...
version_table_impl
python
sqlalchemy/alembic
alembic/ddl/impl.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/ddl/impl.py
MIT
def requires_recreate_in_batch( self, batch_op: BatchOperationsImpl ) -> bool: """Return True if the given :class:`.BatchOperationsImpl` would need the table to be recreated and copied in order to proceed. Normally, only returns True on SQLite when operations other t...
Return True if the given :class:`.BatchOperationsImpl` would need the table to be recreated and copied in order to proceed. Normally, only returns True on SQLite when operations other than add_column are present.
requires_recreate_in_batch
python
sqlalchemy/alembic
alembic/ddl/impl.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/ddl/impl.py
MIT
def prep_table_for_batch( self, batch_impl: ApplyBatchImpl, table: Table ) -> None: """perform any operations needed on a table before a new one is created to replace it in batch mode. the PG dialect uses this to drop constraints on the table before the new one uses those sa...
perform any operations needed on a table before a new one is created to replace it in batch mode. the PG dialect uses this to drop constraints on the table before the new one uses those same names.
prep_table_for_batch
python
sqlalchemy/alembic
alembic/ddl/impl.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/ddl/impl.py
MIT
def _column_args_match( self, inspected_params: Params, meta_params: Params ) -> bool: """We want to compare column parameters. However, we only want to compare parameters that are set. If they both have `collation`, we want to make sure they are the same. However, if only one ...
We want to compare column parameters. However, we only want to compare parameters that are set. If they both have `collation`, we want to make sure they are the same. However, if only one specifies it, dont flag it for being less specific
_column_args_match
python
sqlalchemy/alembic
alembic/ddl/impl.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/ddl/impl.py
MIT
def compare_type( self, inspector_column: Column[Any], metadata_column: Column ) -> bool: """Returns True if there ARE differences between the types of the two columns. Takes impl.type_synonyms into account between retrospected and metadata types """ inspector_params ...
Returns True if there ARE differences between the types of the two columns. Takes impl.type_synonyms into account between retrospected and metadata types
compare_type
python
sqlalchemy/alembic
alembic/ddl/impl.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/ddl/impl.py
MIT
def render_ddl_sql_expr( self, expr: ClauseElement, is_server_default: bool = False, **kw: Any ) -> str: """Render a SQL expression that is typically a server default, index expression, etc. """ compile_kw = {"literal_binds": True, "include_table": False} return st...
Render a SQL expression that is typically a server default, index expression, etc.
render_ddl_sql_expr
python
sqlalchemy/alembic
alembic/ddl/impl.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/ddl/impl.py
MIT
def autogen_column_reflect(self, inspector, table, column_info): """A hook that is attached to the 'column_reflect' event for when a Table is reflected from the database during the autogenerate process. Dialects can elect to modify the information gathered here. """
A hook that is attached to the 'column_reflect' event for when a Table is reflected from the database during the autogenerate process. Dialects can elect to modify the information gathered here.
autogen_column_reflect
python
sqlalchemy/alembic
alembic/ddl/impl.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/ddl/impl.py
MIT
def start_migrations(self) -> None: """A hook called when :meth:`.EnvironmentContext.run_migrations` is called. Implementations can set up per-migration-run state here. """
A hook called when :meth:`.EnvironmentContext.run_migrations` is called. Implementations can set up per-migration-run state here.
start_migrations
python
sqlalchemy/alembic
alembic/ddl/impl.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/ddl/impl.py
MIT
def compare_indexes( self, metadata_index: Index, reflected_index: Index, ) -> ComparisonResult: """Compare two indexes by comparing the signature generated by ``create_index_sig``. This method returns a ``ComparisonResult``. """ msg: List[str] = [] ...
Compare two indexes by comparing the signature generated by ``create_index_sig``. This method returns a ``ComparisonResult``.
compare_indexes
python
sqlalchemy/alembic
alembic/ddl/impl.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/ddl/impl.py
MIT
def compare_unique_constraint( self, metadata_constraint: UniqueConstraint, reflected_constraint: UniqueConstraint, ) -> ComparisonResult: """Compare two unique constraints by comparing the two signatures. The arguments are two tuples that contain the unique constraint and ...
Compare two unique constraints by comparing the two signatures. The arguments are two tuples that contain the unique constraint and the signatures generated by ``create_unique_constraint_sig``. This method returns a ``ComparisonResult``.
compare_unique_constraint
python
sqlalchemy/alembic
alembic/ddl/impl.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/ddl/impl.py
MIT
def _mysql_drop_constraint( element: DropConstraint, compiler: MySQLDDLCompiler, **kw ) -> str: """Redefine SQLAlchemy's drop constraint to raise errors for invalid constraint type.""" constraint = element.element if isinstance( constraint, ( schema.ForeignKeyConstraint,...
Redefine SQLAlchemy's drop constraint to raise errors for invalid constraint type.
_mysql_drop_constraint
python
sqlalchemy/alembic
alembic/ddl/mysql.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/ddl/mysql.py
MIT
def render_ddl_sql_expr( self, expr: ClauseElement, is_server_default: bool = False, is_index: bool = False, **kw: Any, ) -> str: """Render a SQL expression that is typically a server default, index expression, etc. """ # apply self_group to ...
Render a SQL expression that is typically a server default, index expression, etc.
render_ddl_sql_expr
python
sqlalchemy/alembic
alembic/ddl/postgresql.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/ddl/postgresql.py
MIT
def batch_create_exclude_constraint( cls, operations: BatchOperations, constraint_name: str, *elements: Any, **kw: Any, ) -> Optional[Table]: """Issue a "create exclude constraint" instruction using the current batch migration context. .. note:: This...
Issue a "create exclude constraint" instruction using the current batch migration context. .. note:: This method is Postgresql specific, and additionally requires at least SQLAlchemy 1.0. .. seealso:: :meth:`.Operations.create_exclude_constraint`
batch_create_exclude_constraint
python
sqlalchemy/alembic
alembic/ddl/postgresql.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/ddl/postgresql.py
MIT
def requires_recreate_in_batch( self, batch_op: BatchOperationsImpl ) -> bool: """Return True if the given :class:`.BatchOperationsImpl` would need the table to be recreated and copied in order to proceed. Normally, only returns True on SQLite when operations other t...
Return True if the given :class:`.BatchOperationsImpl` would need the table to be recreated and copied in order to proceed. Normally, only returns True on SQLite when operations other than add_column are present.
requires_recreate_in_batch
python
sqlalchemy/alembic
alembic/ddl/sqlite.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/ddl/sqlite.py
MIT
def _guess_if_default_is_unparenthesized_sql_expr( self, expr: Optional[str] ) -> bool: """Determine if a server default is a SQL expression or a constant. There are too many assertions that expect server defaults to round-trip identically without parenthesis added so we will add pa...
Determine if a server default is a SQL expression or a constant. There are too many assertions that expect server defaults to round-trip identically without parenthesis added so we will add parens only in very specific cases.
_guess_if_default_is_unparenthesized_sql_expr
python
sqlalchemy/alembic
alembic/ddl/sqlite.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/ddl/sqlite.py
MIT
def __init__( self, migration_context: MigrationContext, impl: Optional[BatchOperationsImpl] = None, ) -> None: """Construct a new :class:`.Operations` :param migration_context: a :class:`.MigrationContext` instance. """ self.migration_context = mig...
Construct a new :class:`.Operations` :param migration_context: a :class:`.MigrationContext` instance.
__init__
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def register_operation( cls, name: str, sourcename: Optional[str] = None ) -> Callable[[Type[_T]], Type[_T]]: """Register a new operation for this class. This method is normally used to add new operations to the :class:`.Operations` class, and possibly the :class:`.BatchOper...
Register a new operation for this class. This method is normally used to add new operations to the :class:`.Operations` class, and possibly the :class:`.BatchOperations` class as well. All Alembic migration operations are implemented via this system, however the system is also...
register_operation
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def implementation_for(cls, op_cls: Any) -> Callable[[_C], _C]: """Register an implementation for a given :class:`.MigrateOperation`. This is part of the operation extensibility API. .. seealso:: :ref:`operation_plugins` - example of use """ def decorate(fn: _C) ...
Register an implementation for a given :class:`.MigrateOperation`. This is part of the operation extensibility API. .. seealso:: :ref:`operation_plugins` - example of use
implementation_for
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def invoke(self, operation: MigrateOperation) -> Any: """Given a :class:`.MigrateOperation`, invoke it in terms of this :class:`.Operations` instance. """ fn = self._to_impl.dispatch( operation, self.migration_context.impl.__dialect__ ) return fn(self, operat...
Given a :class:`.MigrateOperation`, invoke it in terms of this :class:`.Operations` instance.
invoke
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def inline_literal( self, value: Union[str, int], type_: Optional[TypeEngine[Any]] = None ) -> _literal_bindparam: r"""Produce an 'inline literal' expression, suitable for using in an INSERT, UPDATE, or DELETE statement. When using Alembic in "offline" mode, CRUD operations ...
Produce an 'inline literal' expression, suitable for using in an INSERT, UPDATE, or DELETE statement. When using Alembic in "offline" mode, CRUD operations aren't compatible with SQLAlchemy's default behavior surrounding literal values, which is that they are converted into boun...
inline_literal
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def run_async( self, async_function: Callable[..., Awaitable[_T]], *args: Any, **kw_args: Any, ) -> _T: """Invoke the given asynchronous callable, passing an asynchronous :class:`~sqlalchemy.ext.asyncio.AsyncConnection` as the first argument. This met...
Invoke the given asynchronous callable, passing an asynchronous :class:`~sqlalchemy.ext.asyncio.AsyncConnection` as the first argument. This method allows calling async functions from within the synchronous ``upgrade()`` or ``downgrade()`` alembic migration method. The ...
run_async
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def create_index( self, index_name: Optional[str], table_name: str, columns: Sequence[Union[str, TextClause, ColumnElement[Any]]], *, schema: Optional[str] = None, unique: bool = False, if_not_exists: Optional[bool] = None, ...
Issue a "create index" instruction using the current migration context. e.g.:: from alembic import op op.create_index("ik_test", "t1", ["foo", "bar"]) Functional indexes can be produced by using the :func:`sqlalchemy.sql.expression.text...
create_index
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def create_table( self, table_name: str, *columns: SchemaItem, if_not_exists: Optional[bool] = None, **kw: Any, ) -> Table: r"""Issue a "create table" instruction using the current migration context. This directive ...
Issue a "create table" instruction using the current migration context. This directive receives an argument list similar to that of the traditional :class:`sqlalchemy.schema.Table` construct, but without the metadata:: from sqlalchemy import INTEGER, VAR...
create_table
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def drop_column( self, table_name: str, column_name: str, *, schema: Optional[str] = None, **kw: Any, ) -> None: """Issue a "drop column" instruction using the current migration context. e.g.:: ...
Issue a "drop column" instruction using the current migration context. e.g.:: drop_column("organization", "account_id") :param table_name: name of table :param column_name: name of column :param schema: Optional schema name to operate within...
drop_column
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def drop_constraint( self, constraint_name: str, table_name: str, type_: Optional[str] = None, *, schema: Optional[str] = None, if_exists: Optional[bool] = None, ) -> None: r"""Drop a constraint of the given name, ty...
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 schem...
drop_constraint
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def drop_index( self, index_name: str, table_name: Optional[str] = None, *, schema: Optional[str] = None, if_exists: Optional[bool] = None, **kw: Any, ) -> None: r"""Issue a "drop index" instruction using the current...
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....
drop_index
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def drop_table( self, table_name: str, *, schema: Optional[str] = None, if_exists: Optional[bool] = None, **kw: Any, ) -> None: r"""Issue a "drop table" instruction using the current migration context. ...
Issue a "drop table" instruction using the current migration context. e.g.:: drop_table("accounts") :param table_name: Name of the table :param schema: Optional schema name to operate within. To control quoting of the schema outside of th...
drop_table
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def drop_table_comment( self, table_name: str, *, existing_comment: Optional[str] = None, schema: Optional[str] = None, ) -> None: """Issue a "drop table comment" operation to remove an existing comment set on a table. ...
Issue a "drop table comment" operation to remove an existing comment set on a table. :param table_name: string name of the target table. :param existing_comment: An optional string value of a comment already registered on the specified table. .. seealso:: ...
drop_table_comment
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def add_column( self, column: Column[Any], *, insert_before: Optional[str] = None, insert_after: Optional[str] = None, if_not_exists: Optional[bool] = None, ) -> None: """Issue an "add column" instruction using the current ...
Issue an "add column" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.add_column`
add_column
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def create_exclude_constraint( self, constraint_name: str, *elements: Any, **kw: Any ) -> Optional[Table]: """Issue a "create exclude constraint" instruction using the current batch migration context. .. note:: This method is Postgresql specific, and additionall...
Issue a "create exclude constraint" instruction using the current batch migration context. .. note:: This method is Postgresql specific, and additionally requires at least SQLAlchemy 1.0. .. seealso:: :meth:`.Operations.create_exclude_constraint` ...
create_exclude_constraint
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def create_index( self, index_name: str, columns: List[str], **kw: Any ) -> None: """Issue a "create index" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.create_index` """ # noqa: E501 ...
Issue a "create index" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.create_index`
create_index
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def drop_column(self, column_name: str, **kw: Any) -> None: """Issue a "drop column" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.drop_column` """ # noqa: E501 ...
Issue a "drop column" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.drop_column`
drop_column
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def drop_index(self, index_name: str, **kw: Any) -> None: """Issue a "drop index" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.drop_index` """ # noqa: E501 ...
Issue a "drop index" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.drop_index`
drop_index
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def drop_table_comment( self, *, existing_comment: Optional[str] = None ) -> None: """Issue a "drop table comment" operation to remove an existing comment set on a table using the current batch operations context. :param existing_comment: An optional ...
Issue a "drop table comment" operation to remove an existing comment set on a table using the current batch operations context. :param existing_comment: An optional string value of a comment already registered on the specified table.
drop_table_comment
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def execute( self, sqltext: Union[Executable, str], *, execution_options: Optional[dict[str, Any]] = None, ) -> None: """Execute the given SQL using the current migration context. .. seealso:: :meth:`.Operations.execute` ...
Execute the given SQL using the current migration context. .. seealso:: :meth:`.Operations.execute`
execute
python
sqlalchemy/alembic
alembic/operations/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/base.py
MIT
def create_column_comment(self, column): """the batch table creation function will issue create_column_comment on the real "impl" as part of the create table process. That is, the Column object will have the comment on it already, so when it is received by add_column() it will be a norm...
the batch table creation function will issue create_column_comment on the real "impl" as part of the create table process. That is, the Column object will have the comment on it already, so when it is received by add_column() it will be a normal part of the CREATE TABLE and doesn't need...
create_column_comment
python
sqlalchemy/alembic
alembic/operations/batch.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/batch.py
MIT
def create_table_comment(self, table): """the batch table creation function will issue create_table_comment on the real "impl" as part of the create table process. """
the batch table creation function will issue create_table_comment on the real "impl" as part of the create table process.
create_table_comment
python
sqlalchemy/alembic
alembic/operations/batch.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/batch.py
MIT
def drop_table_comment(self, table): """the batch table creation function will issue drop_table_comment on the real "impl" as part of the create table process. """
the batch table creation function will issue drop_table_comment on the real "impl" as part of the create table process.
drop_table_comment
python
sqlalchemy/alembic
alembic/operations/batch.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/batch.py
MIT
def drop_constraint( cls, operations: Operations, constraint_name: str, table_name: str, type_: Optional[str] = None, *, schema: Optional[str] = None, if_exists: Optional[bool] = None, ) -> None: r"""Drop a constraint of the given name, typical...
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 n...
drop_constraint
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def create_index( cls, operations: Operations, index_name: Optional[str], table_name: str, columns: Sequence[Union[str, TextClause, ColumnElement[Any]]], *, schema: Optional[str] = None, unique: bool = False, if_not_exists: Optional[bool] = None, ...
Issue a "create index" instruction using the current migration context. e.g.:: from alembic import op op.create_index("ik_test", "t1", ["foo", "bar"]) Functional indexes can be produced by using the :func:`sqlalchemy.sql.expression.text` construct:: ...
create_index
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def batch_create_index( cls, operations: BatchOperations, index_name: str, columns: List[str], **kw: Any, ) -> None: """Issue a "create index" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.create_i...
Issue a "create index" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.create_index`
batch_create_index
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def drop_index( cls, operations: Operations, index_name: str, table_name: Optional[str] = None, *, schema: Optional[str] = None, if_exists: Optional[bool] = None, **kw: Any, ) -> None: r"""Issue a "drop index" instruction using the current ...
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: ...
drop_index
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def batch_drop_index( cls, operations: BatchOperations, index_name: str, **kw: Any ) -> None: """Issue a "drop index" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.drop_index` """ op = cls( index_nam...
Issue a "drop index" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.drop_index`
batch_drop_index
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def create_table( cls, operations: Operations, table_name: str, *columns: SchemaItem, if_not_exists: Optional[bool] = None, **kw: Any, ) -> Table: r"""Issue a "create table" instruction using the current migration context. This directive recei...
Issue a "create table" instruction using the current migration context. This directive receives an argument list similar to that of the traditional :class:`sqlalchemy.schema.Table` construct, but without the metadata:: from sqlalchemy import INTEGER, VARCHAR, NVARCHAR, Colu...
create_table
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def drop_table( cls, operations: Operations, table_name: str, *, schema: Optional[str] = None, if_exists: Optional[bool] = None, **kw: Any, ) -> None: r"""Issue a "drop table" instruction using the current migration context. e.g.:: ...
Issue a "drop table" instruction using the current migration context. e.g.:: drop_table("accounts") :param table_name: Name of the table :param schema: Optional schema name to operate within. To control quoting of the schema outside of the default behavior, use ...
drop_table
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def reverse(self) -> Union[CreateTableCommentOp, DropTableCommentOp]: """Reverses the COMMENT ON operation against a table.""" if self.existing_comment is None: return DropTableCommentOp( self.table_name, existing_comment=self.comment, schema=s...
Reverses the COMMENT ON operation against a table.
reverse
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def drop_table_comment( cls, operations: Operations, table_name: str, *, existing_comment: Optional[str] = None, schema: Optional[str] = None, ) -> None: """Issue a "drop table comment" operation to remove an existing comment set on a table. :...
Issue a "drop table comment" operation to remove an existing comment set on a table. :param table_name: string name of the target table. :param existing_comment: An optional string value of a comment already registered on the specified table. .. seealso:: :meth:`....
drop_table_comment
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def batch_drop_table_comment( cls, operations: BatchOperations, *, existing_comment: Optional[str] = None, ) -> None: """Issue a "drop table comment" operation to remove an existing comment set on a table using the current batch operations context. :p...
Issue a "drop table comment" operation to remove an existing comment set on a table using the current batch operations context. :param existing_comment: An optional string value of a comment already registered on the specified table.
batch_drop_table_comment
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def reverse(self) -> CreateTableCommentOp: """Reverses the COMMENT ON operation against a table.""" return CreateTableCommentOp( self.table_name, self.existing_comment, schema=self.schema )
Reverses the COMMENT ON operation against a table.
reverse
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def batch_add_column( cls, operations: BatchOperations, column: Column[Any], *, insert_before: Optional[str] = None, insert_after: Optional[str] = None, if_not_exists: Optional[bool] = None, ) -> None: """Issue an "add column" instruction using the cur...
Issue an "add column" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.add_column`
batch_add_column
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def drop_column( cls, operations: Operations, table_name: str, column_name: str, *, schema: Optional[str] = None, **kw: Any, ) -> None: """Issue a "drop column" instruction using the current migration context. e.g.:: drop_...
Issue a "drop column" instruction using the current migration context. e.g.:: drop_column("organization", "account_id") :param table_name: name of table :param column_name: name of column :param schema: Optional schema name to operate within. To control q...
drop_column
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def batch_drop_column( cls, operations: BatchOperations, column_name: str, **kw: Any ) -> None: """Issue a "drop column" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.drop_column` """ op = cls( operat...
Issue a "drop column" instruction using the current batch migration context. .. seealso:: :meth:`.Operations.drop_column`
batch_drop_column
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def batch_execute( cls, operations: Operations, sqltext: Union[Executable, str], *, execution_options: Optional[dict[str, Any]] = None, ) -> None: """Execute the given SQL using the current migration context. .. seealso:: :meth:`.Operations.execu...
Execute the given SQL using the current migration context. .. seealso:: :meth:`.Operations.execute`
batch_execute
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def upgrade_ops(self) -> Optional[UpgradeOps]: """An instance of :class:`.UpgradeOps`. .. seealso:: :attr:`.MigrationScript.upgrade_ops_list` """ if len(self._upgrade_ops) > 1: raise ValueError( "This MigrationScript instance has a multiple-entry...
An instance of :class:`.UpgradeOps`. .. seealso:: :attr:`.MigrationScript.upgrade_ops_list`
upgrade_ops
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def downgrade_ops(self) -> Optional[DowngradeOps]: """An instance of :class:`.DowngradeOps`. .. seealso:: :attr:`.MigrationScript.downgrade_ops_list` """ if len(self._downgrade_ops) > 1: raise ValueError( "This MigrationScript instance has a mult...
An instance of :class:`.DowngradeOps`. .. seealso:: :attr:`.MigrationScript.downgrade_ops_list`
downgrade_ops
python
sqlalchemy/alembic
alembic/operations/ops.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/ops.py
MIT
def _ensure_table_for_fk(self, metadata: MetaData, fk: ForeignKey) -> None: """create a placeholder Table object for the referent of a ForeignKey. """ if isinstance(fk._colspec, str): table_key, cname = fk._colspec.rsplit(".", 1) sname, tname = self._parse_table_...
create a placeholder Table object for the referent of a ForeignKey.
_ensure_table_for_fk
python
sqlalchemy/alembic
alembic/operations/schemaobj.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/operations/schemaobj.py
MIT
def __init__( self, config: Config, script: ScriptDirectory, **kw: Any ) -> None: r"""Construct a new :class:`.EnvironmentContext`. :param config: a :class:`.Config` instance. :param script: a :class:`.ScriptDirectory` instance. :param \**kw: keyword options that will be ult...
Construct a new :class:`.EnvironmentContext`. :param config: a :class:`.Config` instance. :param script: a :class:`.ScriptDirectory` instance. :param \**kw: keyword options that will be ultimately passed along to the :class:`.MigrationContext` when :meth:`.EnvironmentContext.c...
__init__
python
sqlalchemy/alembic
alembic/runtime/environment.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/environment.py
MIT
def get_starting_revision_argument(self) -> _RevNumber: """Return the 'starting revision' argument, if the revision was passed using ``start:end``. This is only meaningful in "offline" mode. Returns ``None`` if no value is available or was configured. This function does...
Return the 'starting revision' argument, if the revision was passed using ``start:end``. This is only meaningful in "offline" mode. Returns ``None`` if no value is available or was configured. This function does not require that the :class:`.MigrationContext` has been c...
get_starting_revision_argument
python
sqlalchemy/alembic
alembic/runtime/environment.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/environment.py
MIT
def get_x_argument( self, as_dictionary: bool = False ) -> Union[List[str], Dict[str, str]]: """Return the value(s) passed for the ``-x`` argument, if any. The ``-x`` argument is an open ended flag that allows any user-defined value or values to be passed on the command line, then a...
Return the value(s) passed for the ``-x`` argument, if any. The ``-x`` argument is an open ended flag that allows any user-defined value or values to be passed on the command line, then available here for consumption by a custom ``env.py`` script. The return value is a list, returned d...
get_x_argument
python
sqlalchemy/alembic
alembic/runtime/environment.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/environment.py
MIT
def run_migrations(self, **kw: Any) -> None: """Run migrations as determined by the current command line configuration as well as versioning information present (or not) in the current database connection (if one is present). The function accepts optional ``**kw`` arguments. I...
Run migrations as determined by the current command line configuration as well as versioning information present (or not) in the current database connection (if one is present). The function accepts optional ``**kw`` arguments. If these are passed, they are sent directly to th...
run_migrations
python
sqlalchemy/alembic
alembic/runtime/environment.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/environment.py
MIT
def get_context(self) -> MigrationContext: """Return the current :class:`.MigrationContext` object. If :meth:`.EnvironmentContext.configure` has not been called yet, raises an exception. """ if self._migration_context is None: raise Exception("No context has been c...
Return the current :class:`.MigrationContext` object. If :meth:`.EnvironmentContext.configure` has not been called yet, raises an exception.
get_context
python
sqlalchemy/alembic
alembic/runtime/environment.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/environment.py
MIT
def configure( cls, connection: Optional[Connection] = None, url: Optional[Union[str, URL]] = None, dialect_name: Optional[str] = None, dialect: Optional[Dialect] = None, environment_context: Optional[EnvironmentContext] = None, dialect_opts: Optional[Dict[str, st...
Create a new :class:`.MigrationContext`. This is a factory method usually called by :meth:`.EnvironmentContext.configure`. :param connection: a :class:`~sqlalchemy.engine.Connection` to use for SQL execution in "online" mode. When present, is also used to determine the type ...
configure
python
sqlalchemy/alembic
alembic/runtime/migration.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/migration.py
MIT
def get_current_revision(self) -> Optional[str]: """Return the current revision, usually that which is present in the ``alembic_version`` table in the database. This method intends to be used only for a migration stream that does not contain unmerged branches in the target database; ...
Return the current revision, usually that which is present in the ``alembic_version`` table in the database. This method intends to be used only for a migration stream that does not contain unmerged branches in the target database; if there are multiple branches present, an exception is...
get_current_revision
python
sqlalchemy/alembic
alembic/runtime/migration.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/migration.py
MIT
def get_current_heads(self) -> Tuple[str, ...]: """Return a tuple of the current 'head versions' that are represented in the target database. For a migration stream without branches, this will be a single value, synonymous with that of :meth:`.MigrationContext.get_current_revisi...
Return a tuple of the current 'head versions' that are represented in the target database. For a migration stream without branches, this will be a single value, synonymous with that of :meth:`.MigrationContext.get_current_revision`. However when multiple unmerged branches exis...
get_current_heads
python
sqlalchemy/alembic
alembic/runtime/migration.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/migration.py
MIT
def stamp(self, script_directory: ScriptDirectory, revision: str) -> None: """Stamp the version table with a specific revision. This method calculates those branches to which the given revision can apply, and updates those branches as though they were migrated towards that revision (eit...
Stamp the version table with a specific revision. This method calculates those branches to which the given revision can apply, and updates those branches as though they were migrated towards that revision (either up or down). If no current branches include the revision, it is added as ...
stamp
python
sqlalchemy/alembic
alembic/runtime/migration.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/migration.py
MIT
def run_migrations(self, **kw: Any) -> None: r"""Run the migration scripts established for this :class:`.MigrationContext`, if any. The commands in :mod:`alembic.command` will set up a function that is ultimately passed to the :class:`.MigrationContext` as the ``fn`` argument. ...
Run the migration scripts established for this :class:`.MigrationContext`, if any. The commands in :mod:`alembic.command` will set up a function that is ultimately passed to the :class:`.MigrationContext` as the ``fn`` argument. This function represents the "work" that will be ...
run_migrations
python
sqlalchemy/alembic
alembic/runtime/migration.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/migration.py
MIT
def config(self) -> Optional[Config]: """Return the :class:`.Config` used by the current environment, if any.""" if self.environment_context: return self.environment_context.config else: return None
Return the :class:`.Config` used by the current environment, if any.
config
python
sqlalchemy/alembic
alembic/runtime/migration.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/migration.py
MIT
def source_revision_ids(self) -> Tuple[str, ...]: """Active revisions before this migration step is applied.""" return ( self.down_revision_ids if self.is_upgrade else self.up_revision_ids )
Active revisions before this migration step is applied.
source_revision_ids
python
sqlalchemy/alembic
alembic/runtime/migration.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/migration.py
MIT
def destination_revision_ids(self) -> Tuple[str, ...]: """Active revisions after this migration step is applied.""" return ( self.up_revision_ids if self.is_upgrade else self.down_revision_ids )
Active revisions after this migration step is applied.
destination_revision_ids
python
sqlalchemy/alembic
alembic/runtime/migration.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/migration.py
MIT
def should_delete_branch(self, heads: Set[str]) -> bool: """A delete is when we are a. in a downgrade and b. we are going to the "base" or we are going to a version that is implied as a dependency on another version that is remaining. """ if not self.is_downgrade: re...
A delete is when we are a. in a downgrade and b. we are going to the "base" or we are going to a version that is implied as a dependency on another version that is remaining.
should_delete_branch
python
sqlalchemy/alembic
alembic/runtime/migration.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/runtime/migration.py
MIT
def from_config(cls, config: Config) -> ScriptDirectory: """Produce a new :class:`.ScriptDirectory` given a :class:`.Config` instance. The :class:`.Config` need only have the ``script_location`` key present. """ script_location = config.get_alembic_option("script_locati...
Produce a new :class:`.ScriptDirectory` given a :class:`.Config` instance. The :class:`.Config` need only have the ``script_location`` key present.
from_config
python
sqlalchemy/alembic
alembic/script/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/base.py
MIT
def walk_revisions( self, base: str = "base", head: str = "heads" ) -> Iterator[Script]: """Iterate through all revisions. :param base: the base revision, or "base" to start from the empty revision. :param head: the head revision; defaults to "heads" to indicate a...
Iterate through all revisions. :param base: the base revision, or "base" to start from the empty revision. :param head: the head revision; defaults to "heads" to indicate all head revisions. May also be "head" to indicate a single head revision.
walk_revisions
python
sqlalchemy/alembic
alembic/script/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/base.py
MIT
def get_revisions(self, id_: _GetRevArg) -> Tuple[Script, ...]: """Return the :class:`.Script` instance with the given rev identifier, symbolic name, or sequence of identifiers. """ with self._catch_revision_errors(): return cast( Tuple[Script, ...], ...
Return the :class:`.Script` instance with the given rev identifier, symbolic name, or sequence of identifiers.
get_revisions
python
sqlalchemy/alembic
alembic/script/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/base.py
MIT
def get_revision(self, id_: str) -> Script: """Return the :class:`.Script` instance with the given rev id. .. seealso:: :meth:`.ScriptDirectory.get_revisions` """ with self._catch_revision_errors(): return cast(Script, self.revision_map.get_revision(id_))
Return the :class:`.Script` instance with the given rev id. .. seealso:: :meth:`.ScriptDirectory.get_revisions`
get_revision
python
sqlalchemy/alembic
alembic/script/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/base.py
MIT
def as_revision_number( self, id_: Optional[str] ) -> Optional[Union[str, Tuple[str, ...]]]: """Convert a symbolic revision, i.e. 'head' or 'base', into an actual revision number.""" with self._catch_revision_errors(): rev, branch_name = self.revision_map._resolve_revisi...
Convert a symbolic revision, i.e. 'head' or 'base', into an actual revision number.
as_revision_number
python
sqlalchemy/alembic
alembic/script/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/base.py
MIT
def iterate_revisions( self, upper: Union[str, Tuple[str, ...], None], lower: Union[str, Tuple[str, ...], None], **kw: Any, ) -> Iterator[Script]: """Iterate through script revisions, starting at the given upper revision identifier and ending at the lower. Th...
Iterate through script revisions, starting at the given upper revision identifier and ending at the lower. The traversal uses strictly the `down_revision` marker inside each migration script, so it is a requirement that upper >= lower, else you'll get nothing back. The ...
iterate_revisions
python
sqlalchemy/alembic
alembic/script/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/base.py
MIT
def get_current_head(self) -> Optional[str]: """Return the current head revision. If the script directory has multiple heads due to branching, an error is raised; :meth:`.ScriptDirectory.get_heads` should be preferred. :return: a string revision number. .. seea...
Return the current head revision. If the script directory has multiple heads due to branching, an error is raised; :meth:`.ScriptDirectory.get_heads` should be preferred. :return: a string revision number. .. seealso:: :meth:`.ScriptDirectory.get_heads` ...
get_current_head
python
sqlalchemy/alembic
alembic/script/base.py
https://github.com/sqlalchemy/alembic/blob/master/alembic/script/base.py
MIT