Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
context.pyi854 linesDownload Raw Back to alembic
1# ### this file stubs are generated by tools/write_pyi.py - do not edit ###2# ### imports are manually managed3from __future__ import annotations4 5from typing import Any6from typing import Callable7from typing import Collection8from typing import ContextManager9from typing import Dict10from typing import Iterable11from typing import List12from typing import Literal13from typing import Mapping14from typing import MutableMapping15from typing import Optional16from typing import overload17from typing import Sequence18from typing import TextIO19from typing import Tuple20from typing import TYPE_CHECKING21from typing import Union22 23if TYPE_CHECKING:24    from sqlalchemy.engine.base import Connection25    from sqlalchemy.engine.url import URL26    from sqlalchemy.sql import Executable27    from sqlalchemy.sql.schema import Column28    from sqlalchemy.sql.schema import FetchedValue29    from sqlalchemy.sql.schema import MetaData30    from sqlalchemy.sql.schema import SchemaItem31    from sqlalchemy.sql.type_api import TypeEngine32 33    from .autogenerate.api import AutogenContext34    from .config import Config35    from .operations.ops import MigrationScript36    from .runtime.migration import _ProxyTransaction37    from .runtime.migration import MigrationContext38    from .runtime.migration import MigrationInfo39    from .script import ScriptDirectory40 41### end imports ###42 43def begin_transaction() -> Union[_ProxyTransaction, ContextManager[None]]:44    """Return a context manager that will45    enclose an operation within a "transaction",46    as defined by the environment's offline47    and transactional DDL settings.48 49    e.g.::50 51        with context.begin_transaction():52            context.run_migrations()53 54    :meth:`.begin_transaction` is intended to55    "do the right thing" regardless of56    calling context:57 58    * If :meth:`.is_transactional_ddl` is ``False``,59      returns a "do nothing" context manager60      which otherwise produces no transactional61      state or directives.62    * If :meth:`.is_offline_mode` is ``True``,63      returns a context manager that will64      invoke the :meth:`.DefaultImpl.emit_begin`65      and :meth:`.DefaultImpl.emit_commit`66      methods, which will produce the string67      directives ``BEGIN`` and ``COMMIT`` on68      the output stream, as rendered by the69      target backend (e.g. SQL Server would70      emit ``BEGIN TRANSACTION``).71    * Otherwise, calls :meth:`sqlalchemy.engine.Connection.begin`72      on the current online connection, which73      returns a :class:`sqlalchemy.engine.Transaction`74      object.  This object demarcates a real75      transaction and is itself a context manager,76      which will roll back if an exception77      is raised.78 79    Note that a custom ``env.py`` script which80    has more specific transactional needs can of course81    manipulate the :class:`~sqlalchemy.engine.Connection`82    directly to produce transactional state in "online"83    mode.84 85    """86 87config: Config88 89def configure(90    connection: Optional[Connection] = None,91    url: Union[str, URL, None] = None,92    dialect_name: Optional[str] = None,93    dialect_opts: Optional[Dict[str, Any]] = None,94    transactional_ddl: Optional[bool] = None,95    transaction_per_migration: bool = False,96    output_buffer: Optional[TextIO] = None,97    starting_rev: Optional[str] = None,98    tag: Optional[str] = None,99    template_args: Optional[Dict[str, Any]] = None,100    render_as_batch: bool = False,101    target_metadata: Union[MetaData, Sequence[MetaData], None] = None,102    include_name: Optional[103        Callable[104            [105                Optional[str],106                Literal[107                    "schema",108                    "table",109                    "column",110                    "index",111                    "unique_constraint",112                    "foreign_key_constraint",113                ],114                MutableMapping[115                    Literal[116                        "schema_name",117                        "table_name",118                        "schema_qualified_table_name",119                    ],120                    Optional[str],121                ],122            ],123            bool,124        ]125    ] = None,126    include_object: Optional[127        Callable[128            [129                SchemaItem,130                Optional[str],131                Literal[132                    "schema",133                    "table",134                    "column",135                    "index",136                    "unique_constraint",137                    "foreign_key_constraint",138                ],139                bool,140                Optional[SchemaItem],141            ],142            bool,143        ]144    ] = None,145    include_schemas: bool = False,146    process_revision_directives: Optional[147        Callable[148            [149                MigrationContext,150                Union[str, Iterable[Optional[str]], Iterable[str]],151                List[MigrationScript],152            ],153            None,154        ]155    ] = None,156    compare_type: Union[157        bool,158        Callable[159            [160                MigrationContext,161                Column[Any],162                Column[Any],163                TypeEngine[Any],164                TypeEngine[Any],165            ],166            Optional[bool],167        ],168    ] = True,169    compare_server_default: Union[170        bool,171        Callable[172            [173                MigrationContext,174                Column[Any],175                Column[Any],176                Optional[str],177                Optional[FetchedValue],178                Optional[str],179            ],180            Optional[bool],181        ],182    ] = False,183    render_item: Optional[184        Callable[[str, Any, AutogenContext], Union[str, Literal[False]]]185    ] = None,186    literal_binds: bool = False,187    upgrade_token: str = "upgrades",188    downgrade_token: str = "downgrades",189    alembic_module_prefix: str = "op.",190    sqlalchemy_module_prefix: str = "sa.",191    user_module_prefix: Optional[str] = None,192    on_version_apply: Optional[193        Callable[194            [195                MigrationContext,196                MigrationInfo,197                Collection[Any],198                Mapping[str, Any],199            ],200            None,201        ]202    ] = None,203    **kw: Any,204) -> None:205    """Configure a :class:`.MigrationContext` within this206    :class:`.EnvironmentContext` which will provide database207    connectivity and other configuration to a series of208    migration scripts.209 210    Many methods on :class:`.EnvironmentContext` require that211    this method has been called in order to function, as they212    ultimately need to have database access or at least access213    to the dialect in use.  Those which do are documented as such.214 215    The important thing needed by :meth:`.configure` is a216    means to determine what kind of database dialect is in use.217    An actual connection to that database is needed only if218    the :class:`.MigrationContext` is to be used in219    "online" mode.220 221    If the :meth:`.is_offline_mode` function returns ``True``,222    then no connection is needed here.  Otherwise, the223    ``connection`` parameter should be present as an224    instance of :class:`sqlalchemy.engine.Connection`.225 226    This function is typically called from the ``env.py``227    script within a migration environment.  It can be called228    multiple times for an invocation.  The most recent229    :class:`~sqlalchemy.engine.Connection`230    for which it was called is the one that will be operated upon231    by the next call to :meth:`.run_migrations`.232 233    General parameters:234 235    :param connection: a :class:`~sqlalchemy.engine.Connection`236     to use237     for SQL execution in "online" mode.  When present, is also238     used to determine the type of dialect in use.239    :param url: a string database url, or a240     :class:`sqlalchemy.engine.url.URL` object.241     The type of dialect to be used will be derived from this if242     ``connection`` is not passed.243    :param dialect_name: string name of a dialect, such as244     "postgresql", "mssql", etc.245     The type of dialect to be used will be derived from this if246     ``connection`` and ``url`` are not passed.247    :param dialect_opts: dictionary of options to be passed to dialect248     constructor.249    :param transactional_ddl: Force the usage of "transactional"250     DDL on or off;251     this otherwise defaults to whether or not the dialect in252     use supports it.253    :param transaction_per_migration: if True, nest each migration script254     in a transaction rather than the full series of migrations to255     run.256    :param output_buffer: a file-like object that will be used257     for textual output258     when the ``--sql`` option is used to generate SQL scripts.259     Defaults to260     ``sys.stdout`` if not passed here and also not present on261     the :class:`.Config`262     object.  The value here overrides that of the :class:`.Config`263     object.264    :param output_encoding: when using ``--sql`` to generate SQL265     scripts, apply this encoding to the string output.266    :param literal_binds: when using ``--sql`` to generate SQL267     scripts, pass through the ``literal_binds`` flag to the compiler268     so that any literal values that would ordinarily be bound269     parameters are converted to plain strings.270 271     .. warning:: Dialects can typically only handle simple datatypes272        like strings and numbers for auto-literal generation.  Datatypes273        like dates, intervals, and others may still require manual274        formatting, typically using :meth:`.Operations.inline_literal`.275 276     .. note:: the ``literal_binds`` flag is ignored on SQLAlchemy277        versions prior to 0.8 where this feature is not supported.278 279     .. seealso::280 281        :meth:`.Operations.inline_literal`282 283    :param starting_rev: Override the "starting revision" argument284     when using ``--sql`` mode.285    :param tag: a string tag for usage by custom ``env.py`` scripts.286     Set via the ``--tag`` option, can be overridden here.287    :param template_args: dictionary of template arguments which288     will be added to the template argument environment when289     running the "revision" command.   Note that the script environment290     is only run within the "revision" command if the --autogenerate291     option is used, or if the option "revision_environment=true"292     is present in the alembic.ini file.293 294    :param version_table: The name of the Alembic version table.295     The default is ``'alembic_version'``.296    :param version_table_schema: Optional schema to place version297     table within.298    :param version_table_pk: boolean, whether the Alembic version table299     should use a primary key constraint for the "value" column; this300     only takes effect when the table is first created.301     Defaults to True; setting to False should not be necessary and is302     here for backwards compatibility reasons.303    :param on_version_apply: a callable or collection of callables to be304        run for each migration step.305        The callables will be run in the order they are given, once for306        each migration step, after the respective operation has been307        applied but before its transaction is finalized.308        Each callable accepts no positional arguments and the following309        keyword arguments:310 311        * ``ctx``: the :class:`.MigrationContext` running the migration,312        * ``step``: a :class:`.MigrationInfo` representing the313          step currently being applied,314        * ``heads``: a collection of version strings representing the315          current heads,316        * ``run_args``: the ``**kwargs`` passed to :meth:`.run_migrations`.317 318    Parameters specific to the autogenerate feature, when319    ``alembic revision`` is run with the ``--autogenerate`` feature:320 321    :param target_metadata: a :class:`sqlalchemy.schema.MetaData`322     object, or a sequence of :class:`~sqlalchemy.schema.MetaData`323     objects, that will be consulted during autogeneration.324     The tables present in each :class:`~sqlalchemy.schema.MetaData`325     will be compared against326     what is locally available on the target327     :class:`~sqlalchemy.engine.Connection`328     to produce candidate upgrade/downgrade operations.329    :param compare_type: Indicates type comparison behavior during330     an autogenerate331     operation.  Defaults to ``True`` turning on type comparison, which332     has good accuracy on most backends.   See :ref:`compare_types`333     for an example as well as information on other type334     comparison options. Set to ``False`` which disables type335     comparison. A callable can also be passed to provide custom type336     comparison, see :ref:`compare_types` for additional details.337 338     .. versionchanged:: 1.12.0 The default value of339        :paramref:`.EnvironmentContext.configure.compare_type` has been340        changed to ``True``.341 342     .. seealso::343 344        :ref:`compare_types`345 346        :paramref:`.EnvironmentContext.configure.compare_server_default`347 348    :param compare_server_default: Indicates server default comparison349     behavior during350     an autogenerate operation.  Defaults to ``False`` which disables351     server default352     comparison.  Set to  ``True`` to turn on server default comparison,353     which has354     varied accuracy depending on backend.355 356     To customize server default comparison behavior, a callable may357     be specified358     which can filter server default comparisons during an359     autogenerate operation.360     defaults during an autogenerate operation.   The format of this361     callable is::362 363        def my_compare_server_default(context, inspected_column,364                    metadata_column, inspected_default, metadata_default,365                    rendered_metadata_default):366            # return True if the defaults are different,367            # False if not, or None to allow the default implementation368            # to compare these defaults369            return None370 371        context.configure(372            # ...373            compare_server_default = my_compare_server_default374        )375 376     ``inspected_column`` is a dictionary structure as returned by377     :meth:`sqlalchemy.engine.reflection.Inspector.get_columns`, whereas378     ``metadata_column`` is a :class:`sqlalchemy.schema.Column` from379     the local model environment.380 381     A return value of ``None`` indicates to allow default server default382     comparison383     to proceed.  Note that some backends such as Postgresql actually384     execute385     the two defaults on the database side to compare for equivalence.386 387     .. seealso::388 389        :paramref:`.EnvironmentContext.configure.compare_type`390 391    :param include_name: A callable function which is given392     the chance to return ``True`` or ``False`` for any database reflected393     object based on its name, including database schema names when394     the :paramref:`.EnvironmentContext.configure.include_schemas` flag395     is set to ``True``.396 397     The function accepts the following positional arguments:398 399     * ``name``: the name of the object, such as schema name or table name.400       Will be ``None`` when indicating the default schema name of the401       database connection.402     * ``type``: a string describing the type of object; currently403       ``"schema"``, ``"table"``, ``"column"``, ``"index"``,404       ``"unique_constraint"``, or ``"foreign_key_constraint"``405     * ``parent_names``: a dictionary of "parent" object names, that are406       relative to the name being given.  Keys in this dictionary may407       include:  ``"schema_name"``, ``"table_name"`` or408       ``"schema_qualified_table_name"``.409 410     E.g.::411 412        def include_name(name, type_, parent_names):413            if type_ == "schema":414                return name in ["schema_one", "schema_two"]415            else:416                return True417 418        context.configure(419            # ...420            include_schemas = True,421            include_name = include_name422        )423 424     .. seealso::425 426        :ref:`autogenerate_include_hooks`427 428        :paramref:`.EnvironmentContext.configure.include_object`429 430        :paramref:`.EnvironmentContext.configure.include_schemas`431 432 433    :param include_object: A callable function which is given434     the chance to return ``True`` or ``False`` for any object,435     indicating if the given object should be considered in the436     autogenerate sweep.437 438     The function accepts the following positional arguments:439 440     * ``object``: a :class:`~sqlalchemy.schema.SchemaItem` object such441       as a :class:`~sqlalchemy.schema.Table`,442       :class:`~sqlalchemy.schema.Column`,443       :class:`~sqlalchemy.schema.Index`444       :class:`~sqlalchemy.schema.UniqueConstraint`,445       or :class:`~sqlalchemy.schema.ForeignKeyConstraint` object446     * ``name``: the name of the object. This is typically available447       via ``object.name``.448     * ``type``: a string describing the type of object; currently449       ``"table"``, ``"column"``, ``"index"``, ``"unique_constraint"``,450       or ``"foreign_key_constraint"``451     * ``reflected``: ``True`` if the given object was produced based on452       table reflection, ``False`` if it's from a local :class:`.MetaData`453       object.454     * ``compare_to``: the object being compared against, if available,455       else ``None``.456 457     E.g.::458 459        def include_object(object, name, type_, reflected, compare_to):460            if (type_ == "column" and461                not reflected and462                object.info.get("skip_autogenerate", False)):463                return False464            else:465                return True466 467        context.configure(468            # ...469            include_object = include_object470        )471 472     For the use case of omitting specific schemas from a target database473     when :paramref:`.EnvironmentContext.configure.include_schemas` is474     set to ``True``, the :attr:`~sqlalchemy.schema.Table.schema`475     attribute can be checked for each :class:`~sqlalchemy.schema.Table`476     object passed to the hook, however it is much more efficient477     to filter on schemas before reflection of objects takes place478     using the :paramref:`.EnvironmentContext.configure.include_name`479     hook.480 481     .. seealso::482 483        :ref:`autogenerate_include_hooks`484 485        :paramref:`.EnvironmentContext.configure.include_name`486 487        :paramref:`.EnvironmentContext.configure.include_schemas`488 489    :param render_as_batch: if True, commands which alter elements490     within a table will be placed under a ``with batch_alter_table():``491     directive, so that batch migrations will take place.492 493     .. seealso::494 495        :ref:`batch_migrations`496 497    :param include_schemas: If True, autogenerate will scan across498     all schemas located by the SQLAlchemy499     :meth:`~sqlalchemy.engine.reflection.Inspector.get_schema_names`500     method, and include all differences in tables found across all501     those schemas.  When using this option, you may want to also502     use the :paramref:`.EnvironmentContext.configure.include_name`503     parameter to specify a callable which504     can filter the tables/schemas that get included.505 506     .. seealso::507 508        :ref:`autogenerate_include_hooks`509 510        :paramref:`.EnvironmentContext.configure.include_name`511 512        :paramref:`.EnvironmentContext.configure.include_object`513 514    :param render_item: Callable that can be used to override how515     any schema item, i.e. column, constraint, type,516     etc., is rendered for autogenerate.  The callable receives a517     string describing the type of object, the object, and518     the autogen context.  If it returns False, the519     default rendering method will be used.  If it returns None,520     the item will not be rendered in the context of a Table521     construct, that is, can be used to skip columns or constraints522     within op.create_table()::523 524        def my_render_column(type_, col, autogen_context):525            if type_ == "column" and isinstance(col, MySpecialCol):526                return repr(col)527            else:528                return False529 530        context.configure(531            # ...532            render_item = my_render_column533        )534 535     Available values for the type string include: ``"column"``,536     ``"primary_key"``, ``"foreign_key"``, ``"unique"``, ``"check"``,537     ``"type"``, ``"server_default"``.538 539     .. seealso::540 541        :ref:`autogen_render_types`542 543    :param upgrade_token: When autogenerate completes, the text of the544     candidate upgrade operations will be present in this template545     variable when ``script.py.mako`` is rendered.  Defaults to546     ``upgrades``.547    :param downgrade_token: When autogenerate completes, the text of the548     candidate downgrade operations will be present in this549     template variable when ``script.py.mako`` is rendered.  Defaults to550     ``downgrades``.551 552    :param alembic_module_prefix: When autogenerate refers to Alembic553     :mod:`alembic.operations` constructs, this prefix will be used554     (i.e. ``op.create_table``)  Defaults to "``op.``".555     Can be ``None`` to indicate no prefix.556 557    :param sqlalchemy_module_prefix: When autogenerate refers to558     SQLAlchemy559     :class:`~sqlalchemy.schema.Column` or type classes, this prefix560     will be used561     (i.e. ``sa.Column("somename", sa.Integer)``)  Defaults to "``sa.``".562     Can be ``None`` to indicate no prefix.563     Note that when dialect-specific types are rendered, autogenerate564     will render them using the dialect module name, i.e. ``mssql.BIT()``,565     ``postgresql.UUID()``.566 567    :param user_module_prefix: When autogenerate refers to a SQLAlchemy568     type (e.g. :class:`.TypeEngine`) where the module name is not569     under the ``sqlalchemy`` namespace, this prefix will be used570     within autogenerate.  If left at its default of571     ``None``, the ``__module__`` attribute of the type is used to572     render the import module.   It's a good practice to set this573     and to have all custom types be available from a fixed module space,574     in order to future-proof migration files against reorganizations575     in modules.576 577     .. seealso::578 579        :ref:`autogen_module_prefix`580 581    :param process_revision_directives: a callable function that will582     be passed a structure representing the end result of an autogenerate583     or plain "revision" operation, which can be manipulated to affect584     how the ``alembic revision`` command ultimately outputs new585     revision scripts.   The structure of the callable is::586 587        def process_revision_directives(context, revision, directives):588            pass589 590     The ``directives`` parameter is a Python list containing591     a single :class:`.MigrationScript` directive, which represents592     the revision file to be generated.    This list as well as its593     contents may be freely modified to produce any set of commands.594     The section :ref:`customizing_revision` shows an example of595     doing this.  The ``context`` parameter is the596     :class:`.MigrationContext` in use,597     and ``revision`` is a tuple of revision identifiers representing the598     current revision of the database.599 600     The callable is invoked at all times when the ``--autogenerate``601     option is passed to ``alembic revision``.  If ``--autogenerate``602     is not passed, the callable is invoked only if the603     ``revision_environment`` variable is set to True in the Alembic604     configuration, in which case the given ``directives`` collection605     will contain empty :class:`.UpgradeOps` and :class:`.DowngradeOps`606     collections for ``.upgrade_ops`` and ``.downgrade_ops``.  The607     ``--autogenerate`` option itself can be inferred by inspecting608     ``context.config.cmd_opts.autogenerate``.609 610     The callable function may optionally be an instance of611     a :class:`.Rewriter` object.  This is a helper object that612     assists in the production of autogenerate-stream rewriter functions.613 614     .. seealso::615 616         :ref:`customizing_revision`617 618         :ref:`autogen_rewriter`619 620         :paramref:`.command.revision.process_revision_directives`621 622    Parameters specific to individual backends:623 624    :param mssql_batch_separator: The "batch separator" which will625     be placed between each statement when generating offline SQL Server626     migrations.  Defaults to ``GO``.  Note this is in addition to the627     customary semicolon ``;`` at the end of each statement; SQL Server628     considers the "batch separator" to denote the end of an629     individual statement execution, and cannot group certain630     dependent operations in one step.631    :param oracle_batch_separator: The "batch separator" which will632     be placed between each statement when generating offline633     Oracle migrations.  Defaults to ``/``.  Oracle doesn't add a634     semicolon between statements like most other backends.635 636    """637 638def execute(639    sql: Union[Executable, str],640    execution_options: Optional[Dict[str, Any]] = None,641) -> None:642    """Execute the given SQL using the current change context.643 644    The behavior of :meth:`.execute` is the same645    as that of :meth:`.Operations.execute`.  Please see that646    function's documentation for full detail including647    caveats and limitations.648 649    This function requires that a :class:`.MigrationContext` has650    first been made available via :meth:`.configure`.651 652    """653 654def get_bind() -> Connection:655    """Return the current 'bind'.656 657    In "online" mode, this is the658    :class:`sqlalchemy.engine.Connection` currently being used659    to emit SQL to the database.660 661    This function requires that a :class:`.MigrationContext`662    has first been made available via :meth:`.configure`.663 664    """665 666def get_context() -> MigrationContext:667    """Return the current :class:`.MigrationContext` object.668 669    If :meth:`.EnvironmentContext.configure` has not been670    called yet, raises an exception.671 672    """673 674def get_head_revision() -> Union[str, Tuple[str, ...], None]:675    """Return the hex identifier of the 'head' script revision.676 677    If the script directory has multiple heads, this678    method raises a :class:`.CommandError`;679    :meth:`.EnvironmentContext.get_head_revisions` should be preferred.680 681    This function does not require that the :class:`.MigrationContext`682    has been configured.683 684    .. seealso:: :meth:`.EnvironmentContext.get_head_revisions`685 686    """687 688def get_head_revisions() -> Union[str, Tuple[str, ...], None]:689    """Return the hex identifier of the 'heads' script revision(s).690 691    This returns a tuple containing the version number of all692    heads in the script directory.693 694    This function does not require that the :class:`.MigrationContext`695    has been configured.696 697    """698 699def get_revision_argument() -> Union[str, Tuple[str, ...], None]:700    """Get the 'destination' revision argument.701 702    This is typically the argument passed to the703    ``upgrade`` or ``downgrade`` command.704 705    If it was specified as ``head``, the actual706    version number is returned; if specified707    as ``base``, ``None`` is returned.708 709    This function does not require that the :class:`.MigrationContext`710    has been configured.711 712    """713 714def get_starting_revision_argument() -> Union[str, Tuple[str, ...], None]:715    """Return the 'starting revision' argument,716    if the revision was passed using ``start:end``.717 718    This is only meaningful in "offline" mode.719    Returns ``None`` if no value is available720    or was configured.721 722    This function does not require that the :class:`.MigrationContext`723    has been configured.724 725    """726 727def get_tag_argument() -> Optional[str]:728    """Return the value passed for the ``--tag`` argument, if any.729 730    The ``--tag`` argument is not used directly by Alembic,731    but is available for custom ``env.py`` configurations that732    wish to use it; particularly for offline generation scripts733    that wish to generate tagged filenames.734 735    This function does not require that the :class:`.MigrationContext`736    has been configured.737 738    .. seealso::739 740        :meth:`.EnvironmentContext.get_x_argument` - a newer and more741        open ended system of extending ``env.py`` scripts via the command742        line.743 744    """745 746@overload747def get_x_argument(as_dictionary: Literal[False]) -> List[str]: ...748@overload749def get_x_argument(as_dictionary: Literal[True]) -> Dict[str, str]: ...750@overload751def get_x_argument(752    as_dictionary: bool = ...,753) -> Union[List[str], Dict[str, str]]:754    """Return the value(s) passed for the ``-x`` argument, if any.755 756    The ``-x`` argument is an open ended flag that allows any user-defined757    value or values to be passed on the command line, then available758    here for consumption by a custom ``env.py`` script.759 760    The return value is a list, returned directly from the ``argparse``761    structure.  If ``as_dictionary=True`` is passed, the ``x`` arguments762    are parsed using ``key=value`` format into a dictionary that is763    then returned. If there is no ``=`` in the argument, value is an empty764    string.765 766    .. versionchanged:: 1.13.1 Support ``as_dictionary=True`` when767       arguments are passed without the ``=`` symbol.768 769    For example, to support passing a database URL on the command line,770    the standard ``env.py`` script can be modified like this::771 772        cmd_line_url = context.get_x_argument(773            as_dictionary=True).get('dbname')774        if cmd_line_url:775            engine = create_engine(cmd_line_url)776        else:777            engine = engine_from_config(778                    config.get_section(config.config_ini_section),779                    prefix='sqlalchemy.',780                    poolclass=pool.NullPool)781 782    This then takes effect by running the ``alembic`` script as::783 784        alembic -x dbname=postgresql://user:pass@host/dbname upgrade head785 786    This function does not require that the :class:`.MigrationContext`787    has been configured.788 789    .. seealso::790 791        :meth:`.EnvironmentContext.get_tag_argument`792 793        :attr:`.Config.cmd_opts`794 795    """796 797def is_offline_mode() -> bool:798    """Return True if the current migrations environment799    is running in "offline mode".800 801    This is ``True`` or ``False`` depending802    on the ``--sql`` flag passed.803 804    This function does not require that the :class:`.MigrationContext`805    has been configured.806 807    """808 809def is_transactional_ddl() -> bool:810    """Return True if the context is configured to expect a811    transactional DDL capable backend.812 813    This defaults to the type of database in use, and814    can be overridden by the ``transactional_ddl`` argument815    to :meth:`.configure`816 817    This function requires that a :class:`.MigrationContext`818    has first been made available via :meth:`.configure`.819 820    """821 822def run_migrations(**kw: Any) -> None:823    """Run migrations as determined by the current command line824    configuration825    as well as versioning information present (or not) in the current826    database connection (if one is present).827 828    The function accepts optional ``**kw`` arguments.   If these are829    passed, they are sent directly to the ``upgrade()`` and830    ``downgrade()``831    functions within each target revision file.   By modifying the832    ``script.py.mako`` file so that the ``upgrade()`` and ``downgrade()``833    functions accept arguments, parameters can be passed here so that834    contextual information, usually information to identify a particular835    database in use, can be passed from a custom ``env.py`` script836    to the migration functions.837 838    This function requires that a :class:`.MigrationContext` has839    first been made available via :meth:`.configure`.840 841    """842 843script: ScriptDirectory844 845def static_output(text: str) -> None:846    """Emit text directly to the "offline" SQL stream.847 848    Typically this is for emitting comments that849    start with --.  The statement is not treated850    as a SQL execution, no ; or batch separator851    is added, etc.852 853    """854 
codekingpro/portable-devtools · Team Ai