HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //opt/alt/python37/share/doc/alt-python37-alembic/docs/build/api/runtime.rst
.. _alembic.runtime.environment.toplevel:

=======================
Runtime Objects
=======================

The "runtime" of Alembic involves the :class:`.EnvironmentContext`
and :class:`.MigrationContext` objects.   These are the objects that are
in play once the ``env.py`` script is loaded up by a command and
a migration operation proceeds.

The Environment Context
=======================

The :class:`.EnvironmentContext` class provides most of the
API used within an ``env.py`` script.  Within ``env.py``,
the instantated :class:`.EnvironmentContext` is made available
via a special *proxy module* called ``alembic.context``.   That is,
you can import ``alembic.context`` like a regular Python module,
and each name you call upon it is ultimately routed towards the
current :class:`.EnvironmentContext` in use.

In particular, the key method used within ``env.py`` is :meth:`.EnvironmentContext.configure`,
which establishes all the details about how the database will be accessed.

.. automodule:: alembic.runtime.environment
    :members: EnvironmentContext

.. _alembic.runtime.migration.toplevel:

The Migration Context
=====================

The :class:`.MigrationContext` handles the actual work to be performed
against a database backend as migration operations proceed.  It is generally
not exposed to the end-user.

.. automodule:: alembic.runtime.migration
    :members: MigrationContext