Sindbad~EG File Manager
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Configuration — Alembic 0.8.3 documentation</title>
<link rel="stylesheet" href="../_static/nature_override.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/changelog.css" type="text/css" />
<link rel="stylesheet" href="../_static/sphinx_paramlinks.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '0.8.3',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="top" title="Alembic 0.8.3 documentation" href="../index.html" />
<link rel="up" title="API Details" href="index.html" />
<link rel="next" title="Commands" href="commands.html" />
<link rel="prev" title="Runtime Objects" href="runtime.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="commands.html" title="Commands"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="runtime.html" title="Runtime Objects"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Alembic 0.8.3 documentation</a> »</li>
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">API Details</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="configuration">
<span id="alembic-config-toplevel"></span><h1>Configuration<a class="headerlink" href="#configuration" title="Permalink to this headline">¶</a></h1>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">this section discusses the <strong>internal API of Alembic</strong> as
regards internal configuration constructs.
This section is only useful for developers who wish to extend the
capabilities of Alembic. For documentation on configuration of
an Alembic environment, please see <a class="reference internal" href="../tutorial.html"><em>Tutorial</em></a>.</p>
</div>
<p>The <a class="reference internal" href="#alembic.config.Config" title="alembic.config.Config"><code class="xref py py-class docutils literal"><span class="pre">Config</span></code></a> object represents the configuration
passed to the Alembic environment. From an API usage perspective,
it is needed for the following use cases:</p>
<ul class="simple">
<li>to create a <a class="reference internal" href="script.html#alembic.script.ScriptDirectory" title="alembic.script.ScriptDirectory"><code class="xref py py-class docutils literal"><span class="pre">ScriptDirectory</span></code></a>, which allows you to work
with the actual script files in a migration environment</li>
<li>to create an <a class="reference internal" href="runtime.html#alembic.runtime.environment.EnvironmentContext" title="alembic.runtime.environment.EnvironmentContext"><code class="xref py py-class docutils literal"><span class="pre">EnvironmentContext</span></code></a>, which allows you to
actually run the <code class="docutils literal"><span class="pre">env.py</span></code> module within the migration environment</li>
<li>to programatically run any of the commands in the <a class="reference internal" href="commands.html#alembic-command-toplevel"><span>Commands</span></a>
module.</li>
</ul>
<p>The <a class="reference internal" href="#alembic.config.Config" title="alembic.config.Config"><code class="xref py py-class docutils literal"><span class="pre">Config</span></code></a> is <em>not</em> needed for these cases:</p>
<ul class="simple">
<li>to instantiate a <a class="reference internal" href="runtime.html#alembic.runtime.migration.MigrationContext" title="alembic.runtime.migration.MigrationContext"><code class="xref py py-class docutils literal"><span class="pre">MigrationContext</span></code></a> directly - this object
only needs a SQLAlchemy connection or dialect name.</li>
<li>to instantiate a <a class="reference internal" href="../ops.html#alembic.operations.Operations" title="alembic.operations.Operations"><code class="xref py py-class docutils literal"><span class="pre">Operations</span></code></a> object - this object only
needs a <a class="reference internal" href="runtime.html#alembic.runtime.migration.MigrationContext" title="alembic.runtime.migration.MigrationContext"><code class="xref py py-class docutils literal"><span class="pre">MigrationContext</span></code></a>.</li>
</ul>
<span class="target" id="module-alembic.config"></span><dl class="class">
<dt id="alembic.config.Config">
<em class="property">class </em><code class="descclassname">alembic.config.</code><code class="descname">Config</code><span class="sig-paren">(</span><em>file_=None</em>, <em>ini_section='alembic'</em>, <em>output_buffer=None</em>, <em>stdout=<open file '<stdout>'</em>, <em>mode 'w'></em>, <em>cmd_opts=None</em>, <em>config_args=immutabledict({})</em>, <em>attributes=None</em><span class="sig-paren">)</span><a class="headerlink" href="#alembic.config.Config" title="Permalink to this definition">¶</a></dt>
<dd><p>Represent an Alembic configuration.</p>
<p>Within an <code class="docutils literal"><span class="pre">env.py</span></code> script, this is available
via the <a class="reference internal" href="runtime.html#alembic.runtime.environment.EnvironmentContext.config" title="alembic.runtime.environment.EnvironmentContext.config"><code class="xref py py-attr docutils literal"><span class="pre">EnvironmentContext.config</span></code></a> attribute,
which in turn is available at <code class="docutils literal"><span class="pre">alembic.context</span></code>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">alembic</span> <span class="kn">import</span> <span class="n">context</span>
<span class="n">some_param</span> <span class="o">=</span> <span class="n">context</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">get_main_option</span><span class="p">(</span><span class="s">"my option"</span><span class="p">)</span>
</pre></div>
</div>
<p>When invoking Alembic programatically, a new
<a class="reference internal" href="#alembic.config.Config" title="alembic.config.Config"><code class="xref py py-class docutils literal"><span class="pre">Config</span></code></a> can be created by passing
the name of an .ini file to the constructor:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">alembic.config</span> <span class="kn">import</span> <span class="n">Config</span>
<span class="n">alembic_cfg</span> <span class="o">=</span> <span class="n">Config</span><span class="p">(</span><span class="s">"/path/to/yourapp/alembic.ini"</span><span class="p">)</span>
</pre></div>
</div>
<p>With a <a class="reference internal" href="#alembic.config.Config" title="alembic.config.Config"><code class="xref py py-class docutils literal"><span class="pre">Config</span></code></a> object, you can then
run Alembic commands programmatically using the directives
in <a class="reference internal" href="commands.html#module-alembic.command" title="alembic.command"><code class="xref py py-mod docutils literal"><span class="pre">alembic.command</span></code></a>.</p>
<p>The <a class="reference internal" href="#alembic.config.Config" title="alembic.config.Config"><code class="xref py py-class docutils literal"><span class="pre">Config</span></code></a> object can also be constructed without
a filename. Values can be set programmatically, and
new sections will be created as needed:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">alembic.config</span> <span class="kn">import</span> <span class="n">Config</span>
<span class="n">alembic_cfg</span> <span class="o">=</span> <span class="n">Config</span><span class="p">()</span>
<span class="n">alembic_cfg</span><span class="o">.</span><span class="n">set_main_option</span><span class="p">(</span><span class="s">"script_location"</span><span class="p">,</span> <span class="s">"myapp:migrations"</span><span class="p">)</span>
<span class="n">alembic_cfg</span><span class="o">.</span><span class="n">set_main_option</span><span class="p">(</span><span class="s">"url"</span><span class="p">,</span> <span class="s">"postgresql://foo/bar"</span><span class="p">)</span>
<span class="n">alembic_cfg</span><span class="o">.</span><span class="n">set_section_option</span><span class="p">(</span><span class="s">"mysection"</span><span class="p">,</span> <span class="s">"foo"</span><span class="p">,</span> <span class="s">"bar"</span><span class="p">)</span>
</pre></div>
</div>
<p>For passing non-string values to environments, such as connections and
engines, use the <a class="reference internal" href="#alembic.config.Config.attributes" title="alembic.config.Config.attributes"><code class="xref py py-attr docutils literal"><span class="pre">Config.attributes</span></code></a> dictionary:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">with</span> <span class="n">engine</span><span class="o">.</span><span class="n">begin</span><span class="p">()</span> <span class="k">as</span> <span class="n">connection</span><span class="p">:</span>
<span class="n">alembic_cfg</span><span class="o">.</span><span class="n">attributes</span><span class="p">[</span><span class="s">'connection'</span><span class="p">]</span> <span class="o">=</span> <span class="n">connection</span>
<span class="n">command</span><span class="o">.</span><span class="n">upgrade</span><span class="p">(</span><span class="n">alembic_cfg</span><span class="p">,</span> <span class="s">"head"</span><span class="p">)</span>
</pre></div>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><span class="target" id="alembic.config.Config.params.file_"></span><strong>file_</strong><a class="paramlink headerlink reference internal" href="#alembic.config.Config.params.file_">¶</a> – name of the .ini file to open.</li>
<li><span class="target" id="alembic.config.Config.params.ini_section"></span><strong>ini_section</strong><a class="paramlink headerlink reference internal" href="#alembic.config.Config.params.ini_section">¶</a> – name of the main Alembic section within the
.ini file</li>
<li><span class="target" id="alembic.config.Config.params.output_buffer"></span><strong>output_buffer</strong><a class="paramlink headerlink reference internal" href="#alembic.config.Config.params.output_buffer">¶</a> – optional file-like input buffer which
will be passed to the <a class="reference internal" href="runtime.html#alembic.runtime.migration.MigrationContext" title="alembic.runtime.migration.MigrationContext"><code class="xref py py-class docutils literal"><span class="pre">MigrationContext</span></code></a> - used to redirect
the output of “offline generation” when using Alembic programmatically.</li>
<li><span class="target" id="alembic.config.Config.params.stdout"></span><strong>stdout</strong><a class="paramlink headerlink reference internal" href="#alembic.config.Config.params.stdout">¶</a> – <p>buffer where the “print” output of commands will be sent.
Defaults to <code class="docutils literal"><span class="pre">sys.stdout</span></code>.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.4.</span></p>
</div>
</li>
<li><span class="target" id="alembic.config.Config.params.config_args"></span><strong>config_args</strong><a class="paramlink headerlink reference internal" href="#alembic.config.Config.params.config_args">¶</a> – <p>A dictionary of keys and values that will be used
for substitution in the alembic config file. The dictionary as given
is <strong>copied</strong> to a new one, stored locally as the attribute
<code class="docutils literal"><span class="pre">.config_args</span></code>. When the <a class="reference internal" href="#alembic.config.Config.file_config" title="alembic.config.Config.file_config"><code class="xref py py-attr docutils literal"><span class="pre">Config.file_config</span></code></a> attribute is
first invoked, the replacement variable <code class="docutils literal"><span class="pre">here</span></code> will be added to this
dictionary before the dictionary is passed to <code class="docutils literal"><span class="pre">SafeConfigParser()</span></code>
to parse the .ini file.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.7.0.</span></p>
</div>
</li>
<li><span class="target" id="alembic.config.Config.params.attributes"></span><strong>attributes</strong><a class="paramlink headerlink reference internal" href="#alembic.config.Config.params.attributes">¶</a> – <p>optional dictionary of arbitrary Python keys/values,
which will be populated into the <a class="reference internal" href="#alembic.config.Config.attributes" title="alembic.config.Config.attributes"><code class="xref py py-attr docutils literal"><span class="pre">Config.attributes</span></code></a> dictionary.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.7.5.</span></p>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="../cookbook.html#connection-sharing"><span>Sharing a Connection with a Series of Migration Commands and Environments</span></a></p>
</div>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Construct a new <a class="reference internal" href="#alembic.config.Config" title="alembic.config.Config"><code class="xref py py-class docutils literal"><span class="pre">Config</span></code></a></p>
<dl class="attribute">
<dt id="alembic.config.Config.attributes">
<code class="descname">attributes</code><a class="headerlink" href="#alembic.config.Config.attributes" title="Permalink to this definition">¶</a></dt>
<dd><p>A Python dictionary for storage of additional state.</p>
<p>This is a utility dictionary which can include not just strings but
engines, connections, schema objects, or anything else.
Use this to pass objects into an env.py script, such as passing
a <code class="xref py py-class docutils literal"><span class="pre">sqlalchemy.engine.base.Connection</span></code> when calling
commands from <a class="reference internal" href="commands.html#module-alembic.command" title="alembic.command"><code class="xref py py-mod docutils literal"><span class="pre">alembic.command</span></code></a> programmatically.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.7.5.</span></p>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p><a class="reference internal" href="../cookbook.html#connection-sharing"><span>Sharing a Connection with a Series of Migration Commands and Environments</span></a></p>
<p class="last"><a class="reference internal" href="#alembic.config.Config.params.attributes" title="alembic.config.Config"><code class="xref py py-paramref docutils literal"><span class="pre">Config.attributes</span></code></a></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="alembic.config.Config.cmd_opts">
<code class="descname">cmd_opts</code><em class="property"> = None</em><a class="headerlink" href="#alembic.config.Config.cmd_opts" title="Permalink to this definition">¶</a></dt>
<dd><p>The command-line options passed to the <code class="docutils literal"><span class="pre">alembic</span></code> script.</p>
<p>Within an <code class="docutils literal"><span class="pre">env.py</span></code> script this can be accessed via the
<a class="reference internal" href="runtime.html#alembic.runtime.environment.EnvironmentContext.config" title="alembic.runtime.environment.EnvironmentContext.config"><code class="xref py py-attr docutils literal"><span class="pre">EnvironmentContext.config</span></code></a> attribute.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.6.0.</span></p>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="runtime.html#alembic.runtime.environment.EnvironmentContext.get_x_argument" title="alembic.runtime.environment.EnvironmentContext.get_x_argument"><code class="xref py py-meth docutils literal"><span class="pre">EnvironmentContext.get_x_argument()</span></code></a></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="alembic.config.Config.config_file_name">
<code class="descname">config_file_name</code><em class="property"> = None</em><a class="headerlink" href="#alembic.config.Config.config_file_name" title="Permalink to this definition">¶</a></dt>
<dd><p>Filesystem path to the .ini file in use.</p>
</dd></dl>
<dl class="attribute">
<dt id="alembic.config.Config.config_ini_section">
<code class="descname">config_ini_section</code><em class="property"> = None</em><a class="headerlink" href="#alembic.config.Config.config_ini_section" title="Permalink to this definition">¶</a></dt>
<dd><p>Name of the config file section to read basic configuration
from. Defaults to <code class="docutils literal"><span class="pre">alembic</span></code>, that is the <code class="docutils literal"><span class="pre">[alembic]</span></code> section
of the .ini file. This value is modified using the <code class="docutils literal"><span class="pre">-n/--name</span></code>
option to the Alembic runnier.</p>
</dd></dl>
<dl class="attribute">
<dt id="alembic.config.Config.file_config">
<code class="descname">file_config</code><a class="headerlink" href="#alembic.config.Config.file_config" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the underlying <code class="docutils literal"><span class="pre">ConfigParser</span></code> object.</p>
<p>Direct access to the .ini file is available here,
though the <a class="reference internal" href="#alembic.config.Config.get_section" title="alembic.config.Config.get_section"><code class="xref py py-meth docutils literal"><span class="pre">Config.get_section()</span></code></a> and
<a class="reference internal" href="#alembic.config.Config.get_main_option" title="alembic.config.Config.get_main_option"><code class="xref py py-meth docutils literal"><span class="pre">Config.get_main_option()</span></code></a>
methods provide a possibly simpler interface.</p>
</dd></dl>
<dl class="method">
<dt id="alembic.config.Config.get_main_option">
<code class="descname">get_main_option</code><span class="sig-paren">(</span><em>name</em>, <em>default=None</em><span class="sig-paren">)</span><a class="headerlink" href="#alembic.config.Config.get_main_option" title="Permalink to this definition">¶</a></dt>
<dd><p>Return an option from the ‘main’ section of the .ini file.</p>
<p>This defaults to being a key from the <code class="docutils literal"><span class="pre">[alembic]</span></code>
section, unless the <code class="docutils literal"><span class="pre">-n/--name</span></code> flag were used to
indicate a different section.</p>
</dd></dl>
<dl class="method">
<dt id="alembic.config.Config.get_section">
<code class="descname">get_section</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#alembic.config.Config.get_section" title="Permalink to this definition">¶</a></dt>
<dd><p>Return all the configuration options from a given .ini file section
as a dictionary.</p>
</dd></dl>
<dl class="method">
<dt id="alembic.config.Config.get_section_option">
<code class="descname">get_section_option</code><span class="sig-paren">(</span><em>section</em>, <em>name</em>, <em>default=None</em><span class="sig-paren">)</span><a class="headerlink" href="#alembic.config.Config.get_section_option" title="Permalink to this definition">¶</a></dt>
<dd><p>Return an option from the given section of the .ini file.</p>
</dd></dl>
<dl class="method">
<dt id="alembic.config.Config.get_template_directory">
<code class="descname">get_template_directory</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#alembic.config.Config.get_template_directory" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the directory where Alembic setup templates are found.</p>
<p>This method is used by the alembic <code class="docutils literal"><span class="pre">init</span></code> and <code class="docutils literal"><span class="pre">list_templates</span></code>
commands.</p>
</dd></dl>
<dl class="method">
<dt id="alembic.config.Config.print_stdout">
<code class="descname">print_stdout</code><span class="sig-paren">(</span><em>text</em>, <em>*arg</em><span class="sig-paren">)</span><a class="headerlink" href="#alembic.config.Config.print_stdout" title="Permalink to this definition">¶</a></dt>
<dd><p>Render a message to standard out.</p>
</dd></dl>
<dl class="method">
<dt id="alembic.config.Config.set_main_option">
<code class="descname">set_main_option</code><span class="sig-paren">(</span><em>name</em>, <em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#alembic.config.Config.set_main_option" title="Permalink to this definition">¶</a></dt>
<dd><p>Set an option programmatically within the ‘main’ section.</p>
<p>This overrides whatever was in the .ini file.</p>
</dd></dl>
<dl class="method">
<dt id="alembic.config.Config.set_section_option">
<code class="descname">set_section_option</code><span class="sig-paren">(</span><em>section</em>, <em>name</em>, <em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#alembic.config.Config.set_section_option" title="Permalink to this definition">¶</a></dt>
<dd><p>Set an option programmatically within the given section.</p>
<p>The section is created if it doesn’t exist already.
The value here will override whatever was in the .ini
file.</p>
</dd></dl>
</dd></dl>
<dl class="function">
<dt id="alembic.config.main">
<code class="descclassname">alembic.config.</code><code class="descname">main</code><span class="sig-paren">(</span><em>argv=None</em>, <em>prog=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#alembic.config.main" title="Permalink to this definition">¶</a></dt>
<dd><p>The console runner function for Alembic.</p>
</dd></dl>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="runtime.html"
title="previous chapter">Runtime Objects</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="commands.html"
title="next chapter">Commands</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/api/config.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="commands.html" title="Commands"
>next</a> |</li>
<li class="right" >
<a href="runtime.html" title="Runtime Objects"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Alembic 0.8.3 documentation</a> »</li>
<li class="nav-item nav-item-1"><a href="index.html" >API Details</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2010-2015, Mike Bayer.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.3.1.
</div>
</body>
</html>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists