blob: 60f04f987be0e994d8e281940160affdc1ca71bb [file] [log] [blame]
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>airflow.contrib.hooks.gcp_sql_hook &mdash; Airflow Documentation</title>
<script type="text/javascript" src="../../../../../_static/js/modernizr.min.js"></script>
<script type="text/javascript" id="documentation_options" data-url_root="../../../../../" src="../../../../../_static/documentation_options.js"></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>
<script type="text/javascript" src="../../../../../_static/language_data.js"></script>
<script type="text/javascript" src="../../../../../_static/js/theme.js"></script>
<link rel="stylesheet" href="../../../../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../../../../_static/pygments.css" type="text/css" />
<link rel="index" title="Index" href="../../../../../genindex.html" />
<link rel="search" title="Search" href="../../../../../search.html" />
<link rel="next" title="airflow.contrib.hooks.gcp_text_to_speech_hook" href="../gcp_text_to_speech_hook/index.html" />
<link rel="prev" title="airflow.contrib.hooks.gcp_speech_to_text_hook" href="../gcp_speech_to_text_hook/index.html" />
<script>
document.addEventListener('DOMContentLoaded', function() {
var el = document.getElementById('changelog');
if (el !== null ) {
// [AIRFLOW-...]
el.innerHTML = el.innerHTML.replace(
/\[(AIRFLOW-[\d]+)\]/g,
`<a href="https://issues.apache.org/jira/browse/$1">[$1]</a>`
);
// (#...)
el.innerHTML = el.innerHTML.replace(
/\(#([\d]+)\)/g,
`<a href="https://github.com/apache/airflow/pull/$1">(#$1)</a>`
);
};
})
</script>
<style>
.example-header {
position: relative;
background: #9AAA7A;
padding: 8px 16px;
margin-bottom: 0;
}
.example-header--with-button {
padding-right: 166px;
}
.example-header:after{
content: '';
display: table;
clear: both;
}
.example-title {
display:block;
padding: 4px;
margin-right: 16px;
color: white;
overflow-x: auto;
}
.example-header-button {
top: 8px;
right: 16px;
position: absolute;
}
.example-header + .highlight-python {
margin-top: 0 !important;
}
.viewcode-button {
display: inline-block;
padding: 8px 16px;
border: 0;
margin: 0;
outline: 0;
border-radius: 2px;
-webkit-box-shadow: 0 3px 5px 0 rgba(0,0,0,.3);
box-shadow: 0 3px 6px 0 rgba(0,0,0,.3);
color: #404040;
background-color: #e7e7e7;
cursor: pointer;
font-size: 16px;
font-weight: 500;
line-height: 1;
text-decoration: none;
text-overflow: ellipsis;
overflow: hidden;
text-transform: uppercase;
-webkit-transition: background-color .2s;
transition: background-color .2s;
vertical-align: middle;
white-space: nowrap;
}
.viewcode-button:visited {
color: #404040;
}
.viewcode-button:hover, .viewcode-button:focus {
color: #404040;
background-color: #d6d6d6;
}
</style>
<script type="application/javascript">
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga("create", "UA-140539454-1", "auto");
ga("send", "pageview");
</script>
<script async src="https://www.google-analytics.com/analytics.js"></script>
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../../../../index.html" class="icon icon-home"> Airflow
</a>
<div class="version">
1.10.4
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../../../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../../../../project.html">Project</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../license.html">License</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../start.html">Quick Start</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../tutorial.html">Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../howto/index.html">How-to Guides</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../ui.html">UI / Screenshots</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../concepts.html">Concepts</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../profiling.html">Data Profiling</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../cli.html">Command Line Interface</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../scheduler.html">Scheduling &amp; Triggers</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../plugins.html">Plugins</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../security.html">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../timezone.html">Time zones</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../api.html">Experimental Rest API</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../integration.html">Integration</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../metrics.html">Metrics</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../kubernetes.html">Kubernetes</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../lineage.html">Lineage</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../changelog.html">Changelog</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../faq.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../../macros.html">Macros reference</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../../../../index.html">API Reference</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../../../../index.html#operators">Operators</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../../../../index.html#hooks">Hooks</a><ul class="current">
<li class="toctree-l3 current"><a class="reference internal" href="../../../../index.html#hooks-packages">Hooks packages</a><ul class="current">
<li class="toctree-l4"><a class="reference internal" href="../../../hooks/index.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">airflow.hooks</span></code></a></li>
<li class="toctree-l4 current"><a class="reference internal" href="../index.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">airflow.contrib.hooks</span></code></a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../../index.html#executors">Executors</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../../index.html#models">Models</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../../index.html#core-and-community-package">Core and community package</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../../../../index.html">Airflow</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../../../../index.html">Docs</a> &raquo;</li>
<li><a href="../../../../index.html">API Reference</a> &raquo;</li>
<li><a href="../index.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">airflow.contrib.hooks</span></code></a> &raquo;</li>
<li><code class="xref py py-mod docutils literal notranslate"><span class="pre">airflow.contrib.hooks.gcp_sql_hook</span></code></li>
<li class="wy-breadcrumbs-aside">
<a href="../../../../../_sources/_api/airflow/contrib/hooks/gcp_sql_hook/index.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="module-airflow.contrib.hooks.gcp_sql_hook">
<span id="airflow-contrib-hooks-gcp-sql-hook"></span><h1><a class="reference internal" href="#module-airflow.contrib.hooks.gcp_sql_hook" title="airflow.contrib.hooks.gcp_sql_hook"><code class="xref py py-mod docutils literal notranslate"><span class="pre">airflow.contrib.hooks.gcp_sql_hook</span></code></a><a class="headerlink" href="#module-airflow.contrib.hooks.gcp_sql_hook" title="Permalink to this headline"></a></h1>
<div class="section" id="module-contents">
<h2>Module Contents<a class="headerlink" href="#module-contents" title="Permalink to this headline"></a></h2>
<dl class="data">
<dt id="airflow.contrib.hooks.gcp_sql_hook.UNIX_PATH_MAX">
<code class="sig-prename descclassname">airflow.contrib.hooks.gcp_sql_hook.</code><code class="sig-name descname">UNIX_PATH_MAX</code><em class="property"> = 108</em><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#UNIX_PATH_MAX"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.UNIX_PATH_MAX" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="data">
<dt id="airflow.contrib.hooks.gcp_sql_hook.TIME_TO_SLEEP_IN_SECONDS">
<code class="sig-prename descclassname">airflow.contrib.hooks.gcp_sql_hook.</code><code class="sig-name descname">TIME_TO_SLEEP_IN_SECONDS</code><em class="property"> = 1</em><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#TIME_TO_SLEEP_IN_SECONDS"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.TIME_TO_SLEEP_IN_SECONDS" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="class">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlOperationStatus">
<em class="property">class </em><code class="sig-prename descclassname">airflow.contrib.hooks.gcp_sql_hook.</code><code class="sig-name descname">CloudSqlOperationStatus</code><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlOperationStatus"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlOperationStatus" title="Permalink to this definition"></a></dt>
<dd><dl class="attribute">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlOperationStatus.PENDING">
<code class="sig-name descname">PENDING</code><em class="property"> = PENDING</em><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlOperationStatus.PENDING"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlOperationStatus.PENDING" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlOperationStatus.RUNNING">
<code class="sig-name descname">RUNNING</code><em class="property"> = RUNNING</em><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlOperationStatus.RUNNING"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlOperationStatus.RUNNING" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlOperationStatus.DONE">
<code class="sig-name descname">DONE</code><em class="property"> = DONE</em><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlOperationStatus.DONE"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlOperationStatus.DONE" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlOperationStatus.UNKNOWN">
<code class="sig-name descname">UNKNOWN</code><em class="property"> = UNKNOWN</em><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlOperationStatus.UNKNOWN"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlOperationStatus.UNKNOWN" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook">
<em class="property">class </em><code class="sig-prename descclassname">airflow.contrib.hooks.gcp_sql_hook.</code><code class="sig-name descname">CloudSqlHook</code><span class="sig-paren">(</span><em class="sig-param">api_version</em>, <em class="sig-param">gcp_conn_id='google_cloud_default'</em>, <em class="sig-param">delegate_to=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlHook"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="../gcp_api_base_hook/index.html#airflow.contrib.hooks.gcp_api_base_hook.GoogleCloudBaseHook" title="airflow.contrib.hooks.gcp_api_base_hook.GoogleCloudBaseHook"><code class="xref py py-class docutils literal notranslate"><span class="pre">airflow.contrib.hooks.gcp_api_base_hook.GoogleCloudBaseHook</span></code></a></p>
<p>Hook for Google Cloud SQL APIs.</p>
<p>All the methods in the hook where project_id is used must be called with
keyword arguments rather than positional.</p>
<dl class="attribute">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook._conn">
<code class="sig-name descname">_conn</code><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlHook._conn"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook._conn" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook.get_conn">
<code class="sig-name descname">get_conn</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlHook.get_conn"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook.get_conn" title="Permalink to this definition"></a></dt>
<dd><p>Retrieves connection to Cloud SQL.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>Google Cloud SQL services object.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.7)">dict</a></p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook.get_instance">
<code class="sig-name descname">get_instance</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">instance</em>, <em class="sig-param">project_id=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlHook.get_instance"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook.get_instance" title="Permalink to this definition"></a></dt>
<dd><p>Retrieves a resource containing information about a Cloud SQL instance.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>instance</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Database instance ID. This does not include the project ID.</p></li>
<li><p><strong>project_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Project ID of the project that contains the instance. If set
to None or missing, the default project_id from the GCP connection is used.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A Cloud SQL instance resource.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.7)">dict</a></p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook.create_instance">
<code class="sig-name descname">create_instance</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">body</em>, <em class="sig-param">project_id=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlHook.create_instance"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook.create_instance" title="Permalink to this definition"></a></dt>
<dd><p>Creates a new Cloud SQL instance.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>body</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.7)"><em>dict</em></a>) – Body required by the Cloud SQL insert API, as described in
<a class="reference external" href="https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/instances/insert#request-body">https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/instances/insert#request-body</a>.</p></li>
<li><p><strong>project_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Project ID of the project that contains the instance. If set
to None or missing, the default project_id from the GCP connection is used.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>None</p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook.patch_instance">
<code class="sig-name descname">patch_instance</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">body</em>, <em class="sig-param">instance</em>, <em class="sig-param">project_id=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlHook.patch_instance"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook.patch_instance" title="Permalink to this definition"></a></dt>
<dd><p>Updates settings of a Cloud SQL instance.</p>
<p>Caution: This is not a partial update, so you must include values for
all the settings that you want to retain.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>body</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.7)"><em>dict</em></a>) – Body required by the Cloud SQL patch API, as described in
<a class="reference external" href="https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/instances/patch#request-body">https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/instances/patch#request-body</a>.</p></li>
<li><p><strong>instance</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Cloud SQL instance ID. This does not include the project ID.</p></li>
<li><p><strong>project_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Project ID of the project that contains the instance. If set
to None or missing, the default project_id from the GCP connection is used.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>None</p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook.delete_instance">
<code class="sig-name descname">delete_instance</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">instance</em>, <em class="sig-param">project_id=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlHook.delete_instance"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook.delete_instance" title="Permalink to this definition"></a></dt>
<dd><p>Deletes a Cloud SQL instance.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>project_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Project ID of the project that contains the instance. If set
to None or missing, the default project_id from the GCP connection is used.</p></li>
<li><p><strong>instance</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Cloud SQL instance ID. This does not include the project ID.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>None</p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook.get_database">
<code class="sig-name descname">get_database</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">instance</em>, <em class="sig-param">database</em>, <em class="sig-param">project_id=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlHook.get_database"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook.get_database" title="Permalink to this definition"></a></dt>
<dd><p>Retrieves a database resource from a Cloud SQL instance.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>instance</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Database instance ID. This does not include the project ID.</p></li>
<li><p><strong>database</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Name of the database in the instance.</p></li>
<li><p><strong>project_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Project ID of the project that contains the instance. If set
to None or missing, the default project_id from the GCP connection is used.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A Cloud SQL database resource, as described in
<a class="reference external" href="https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/databases#resource">https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/databases#resource</a>.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.7)">dict</a></p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook.create_database">
<code class="sig-name descname">create_database</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">instance</em>, <em class="sig-param">body</em>, <em class="sig-param">project_id=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlHook.create_database"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook.create_database" title="Permalink to this definition"></a></dt>
<dd><p>Creates a new database inside a Cloud SQL instance.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>instance</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Database instance ID. This does not include the project ID.</p></li>
<li><p><strong>body</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.7)"><em>dict</em></a>) – The request body, as described in
<a class="reference external" href="https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/databases/insert#request-body">https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/databases/insert#request-body</a>.</p></li>
<li><p><strong>project_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Project ID of the project that contains the instance. If set
to None or missing, the default project_id from the GCP connection is used.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>None</p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook.patch_database">
<code class="sig-name descname">patch_database</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">instance</em>, <em class="sig-param">database</em>, <em class="sig-param">body</em>, <em class="sig-param">project_id=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlHook.patch_database"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook.patch_database" title="Permalink to this definition"></a></dt>
<dd><p>Updates a database resource inside a Cloud SQL instance.</p>
<p>This method supports patch semantics.
See <a class="reference external" href="https://cloud.google.com/sql/docs/mysql/admin-api/how-tos/performance#patch">https://cloud.google.com/sql/docs/mysql/admin-api/how-tos/performance#patch</a>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>instance</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Database instance ID. This does not include the project ID.</p></li>
<li><p><strong>database</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Name of the database to be updated in the instance.</p></li>
<li><p><strong>body</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.7)"><em>dict</em></a>) – The request body, as described in
<a class="reference external" href="https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/databases/insert#request-body">https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/databases/insert#request-body</a>.</p></li>
<li><p><strong>project_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Project ID of the project that contains the instance. If set
to None or missing, the default project_id from the GCP connection is used.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>None</p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook.delete_database">
<code class="sig-name descname">delete_database</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">instance</em>, <em class="sig-param">database</em>, <em class="sig-param">project_id=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlHook.delete_database"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook.delete_database" title="Permalink to this definition"></a></dt>
<dd><p>Deletes a database from a Cloud SQL instance.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>instance</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Database instance ID. This does not include the project ID.</p></li>
<li><p><strong>database</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Name of the database to be deleted in the instance.</p></li>
<li><p><strong>project_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Project ID of the project that contains the instance. If set
to None or missing, the default project_id from the GCP connection is used.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>None</p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook.export_instance">
<code class="sig-name descname">export_instance</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">instance</em>, <em class="sig-param">body</em>, <em class="sig-param">project_id=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlHook.export_instance"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook.export_instance" title="Permalink to this definition"></a></dt>
<dd><p>Exports data from a Cloud SQL instance to a Cloud Storage bucket as a SQL dump
or CSV file.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>instance</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Database instance ID of the Cloud SQL instance. This does not include the
project ID.</p></li>
<li><p><strong>body</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.7)"><em>dict</em></a>) – The request body, as described in
<a class="reference external" href="https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/instances/export#request-body">https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/instances/export#request-body</a></p></li>
<li><p><strong>project_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Project ID of the project that contains the instance. If set
to None or missing, the default project_id from the GCP connection is used.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>None</p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook.import_instance">
<code class="sig-name descname">import_instance</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">instance</em>, <em class="sig-param">body</em>, <em class="sig-param">project_id=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlHook.import_instance"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook.import_instance" title="Permalink to this definition"></a></dt>
<dd><p>Imports data into a Cloud SQL instance from a SQL dump or CSV file in
Cloud Storage.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>instance</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Database instance ID. This does not include the
project ID.</p></li>
<li><p><strong>body</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.7)"><em>dict</em></a>) – The request body, as described in
<a class="reference external" href="https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/instances/export#request-body">https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/instances/export#request-body</a></p></li>
<li><p><strong>project_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Project ID of the project that contains the instance. If set
to None or missing, the default project_id from the GCP connection is used.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>None</p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook._wait_for_operation_to_complete">
<code class="sig-name descname">_wait_for_operation_to_complete</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">project_id</em>, <em class="sig-param">operation_name</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlHook._wait_for_operation_to_complete"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlHook._wait_for_operation_to_complete" title="Permalink to this definition"></a></dt>
<dd><p>Waits for the named operation to complete - checks status of the
asynchronous call.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>project_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Project ID of the project that contains the instance.</p></li>
<li><p><strong>operation_name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Name of the operation.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>None</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dl class="data">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CLOUD_SQL_PROXY_DOWNLOAD_URL">
<code class="sig-prename descclassname">airflow.contrib.hooks.gcp_sql_hook.</code><code class="sig-name descname">CLOUD_SQL_PROXY_DOWNLOAD_URL</code><em class="property"> = https://dl.google.com/cloudsql/cloud_sql_proxy.{}.{}</em><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CLOUD_SQL_PROXY_DOWNLOAD_URL"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CLOUD_SQL_PROXY_DOWNLOAD_URL" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="data">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CLOUD_SQL_PROXY_VERSION_DOWNLOAD_URL">
<code class="sig-prename descclassname">airflow.contrib.hooks.gcp_sql_hook.</code><code class="sig-name descname">CLOUD_SQL_PROXY_VERSION_DOWNLOAD_URL</code><em class="property"> = https://storage.googleapis.com/cloudsql-proxy/{}/cloud_sql_proxy.{}.{}</em><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CLOUD_SQL_PROXY_VERSION_DOWNLOAD_URL"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CLOUD_SQL_PROXY_VERSION_DOWNLOAD_URL" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="data">
<dt id="airflow.contrib.hooks.gcp_sql_hook.GCP_CREDENTIALS_KEY_PATH">
<code class="sig-prename descclassname">airflow.contrib.hooks.gcp_sql_hook.</code><code class="sig-name descname">GCP_CREDENTIALS_KEY_PATH</code><em class="property"> = extra__google_cloud_platform__key_path</em><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#GCP_CREDENTIALS_KEY_PATH"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.GCP_CREDENTIALS_KEY_PATH" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="data">
<dt id="airflow.contrib.hooks.gcp_sql_hook.GCP_CREDENTIALS_KEYFILE_DICT">
<code class="sig-prename descclassname">airflow.contrib.hooks.gcp_sql_hook.</code><code class="sig-name descname">GCP_CREDENTIALS_KEYFILE_DICT</code><em class="property"> = extra__google_cloud_platform__keyfile_dict</em><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#GCP_CREDENTIALS_KEYFILE_DICT"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.GCP_CREDENTIALS_KEYFILE_DICT" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="class">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlProxyRunner">
<em class="property">class </em><code class="sig-prename descclassname">airflow.contrib.hooks.gcp_sql_hook.</code><code class="sig-name descname">CloudSqlProxyRunner</code><span class="sig-paren">(</span><em class="sig-param">path_prefix</em>, <em class="sig-param">instance_specification</em>, <em class="sig-param">gcp_conn_id='google_cloud_default'</em>, <em class="sig-param">project_id=None</em>, <em class="sig-param">sql_proxy_version=None</em>, <em class="sig-param">sql_proxy_binary_path=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlProxyRunner"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlProxyRunner" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">airflow.LoggingMixin</span></code></p>
<p>Downloads and runs cloud-sql-proxy as subprocess of the Python process.</p>
<p>The cloud-sql-proxy needs to be downloaded and started before we can connect
to the Google Cloud SQL instance via database connection. It establishes
secure tunnel connection to the database. It authorizes using the
GCP credentials that are passed by the configuration.</p>
<p>More details about the proxy can be found here:
<a class="reference external" href="https://cloud.google.com/sql/docs/mysql/sql-proxy">https://cloud.google.com/sql/docs/mysql/sql-proxy</a></p>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlProxyRunner._build_command_line_parameters">
<code class="sig-name descname">_build_command_line_parameters</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlProxyRunner._build_command_line_parameters"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlProxyRunner._build_command_line_parameters" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlProxyRunner._is_os_64bit">
<em class="property">static </em><code class="sig-name descname">_is_os_64bit</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlProxyRunner._is_os_64bit"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlProxyRunner._is_os_64bit" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlProxyRunner._download_sql_proxy_if_needed">
<code class="sig-name descname">_download_sql_proxy_if_needed</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlProxyRunner._download_sql_proxy_if_needed"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlProxyRunner._download_sql_proxy_if_needed" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlProxyRunner._get_credential_parameters">
<code class="sig-name descname">_get_credential_parameters</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">session</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlProxyRunner._get_credential_parameters"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlProxyRunner._get_credential_parameters" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlProxyRunner.start_proxy">
<code class="sig-name descname">start_proxy</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlProxyRunner.start_proxy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlProxyRunner.start_proxy" title="Permalink to this definition"></a></dt>
<dd><p>Starts Cloud SQL Proxy.</p>
<p>You have to remember to stop the proxy if you started it!</p>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlProxyRunner.stop_proxy">
<code class="sig-name descname">stop_proxy</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlProxyRunner.stop_proxy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlProxyRunner.stop_proxy" title="Permalink to this definition"></a></dt>
<dd><p>Stops running proxy.</p>
<p>You should stop the proxy after you stop using it.</p>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlProxyRunner.get_proxy_version">
<code class="sig-name descname">get_proxy_version</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlProxyRunner.get_proxy_version"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlProxyRunner.get_proxy_version" title="Permalink to this definition"></a></dt>
<dd><p>Returns version of the Cloud SQL Proxy.</p>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlProxyRunner.get_socket_path">
<code class="sig-name descname">get_socket_path</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlProxyRunner.get_socket_path"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlProxyRunner.get_socket_path" title="Permalink to this definition"></a></dt>
<dd><p>Retrieves UNIX socket path used by Cloud SQL Proxy.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>The dynamically generated path for the socket created by the proxy.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)">str</a></p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dl class="data">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CONNECTION_URIS">
<code class="sig-prename descclassname">airflow.contrib.hooks.gcp_sql_hook.</code><code class="sig-name descname">CONNECTION_URIS</code><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CONNECTION_URIS"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CONNECTION_URIS" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="data">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CLOUD_SQL_VALID_DATABASE_TYPES">
<code class="sig-prename descclassname">airflow.contrib.hooks.gcp_sql_hook.</code><code class="sig-name descname">CLOUD_SQL_VALID_DATABASE_TYPES</code><em class="property"> = ['postgres', 'mysql']</em><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CLOUD_SQL_VALID_DATABASE_TYPES"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CLOUD_SQL_VALID_DATABASE_TYPES" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="class">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook">
<em class="property">class </em><code class="sig-prename descclassname">airflow.contrib.hooks.gcp_sql_hook.</code><code class="sig-name descname">CloudSqlDatabaseHook</code><span class="sig-paren">(</span><em class="sig-param">gcp_cloudsql_conn_id='google_cloud_sql_default'</em>, <em class="sig-param">gcp_conn_id='google_cloud_default'</em>, <em class="sig-param">default_gcp_project_id=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlDatabaseHook"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="../../../hooks/base_hook/index.html#airflow.hooks.base_hook.BaseHook" title="airflow.hooks.base_hook.BaseHook"><code class="xref py py-class docutils literal notranslate"><span class="pre">airflow.hooks.base_hook.BaseHook</span></code></a></p>
<p>Serves DB connection configuration for Google Cloud SQL (Connections
of <em>gcpcloudsql://</em> type).</p>
<p>The hook is a “meta” one. It does not perform an actual connection.
It is there to retrieve all the parameters configured in gcpcloudsql:// connection,
start/stop Cloud SQL Proxy if needed, dynamically generate Postgres or MySQL
connection in the database and return an actual Postgres or MySQL hook.
The returned Postgres/MySQL hooks are using direct connection or Cloud SQL
Proxy socket/TCP as configured.</p>
<p>Main parameters of the hook are retrieved from the standard URI components:</p>
<ul class="simple">
<li><p><strong>user</strong> - User name to authenticate to the database (from login of the URI).</p></li>
<li><p><strong>password</strong> - Password to authenticate to the database (from password of the URI).</p></li>
<li><p><strong>public_ip</strong> - IP to connect to for public connection (from host of the URI).</p></li>
<li><p><strong>public_port</strong> - Port to connect to for public connection (from port of the URI).</p></li>
<li><p><strong>database</strong> - Database to connect to (from schema of the URI).</p></li>
</ul>
<p>Remaining parameters are retrieved from the extras (URI query parameters):</p>
<ul class="simple">
<li><dl class="simple">
<dt><strong>project_id</strong> - Optional, Google Cloud Platform project where the Cloud SQL</dt><dd><p>instance exists. If missing, default project id passed is used.</p>
</dd>
</dl>
</li>
<li><p><strong>instance</strong> - Name of the instance of the Cloud SQL database instance.</p></li>
<li><p><strong>location</strong> - The location of the Cloud SQL instance (for example europe-west1).</p></li>
<li><p><strong>database_type</strong> - The type of the database instance (MySQL or Postgres).</p></li>
<li><p><strong>use_proxy</strong> - (default False) Whether SQL proxy should be used to connect to Cloud
SQL DB.</p></li>
<li><p><strong>use_ssl</strong> - (default False) Whether SSL should be used to connect to Cloud SQL DB.
You cannot use proxy and SSL together.</p></li>
<li><p><strong>sql_proxy_use_tcp</strong> - (default False) If set to true, TCP is used to connect via
proxy, otherwise UNIX sockets are used.</p></li>
<li><p><strong>sql_proxy_binary_path</strong> - Optional path to Cloud SQL Proxy binary. If the binary
is not specified or the binary is not present, it is automatically downloaded.</p></li>
<li><p><strong>sql_proxy_version</strong> - Specific version of the proxy to download (for example
v1.13). If not specified, the latest version is downloaded.</p></li>
<li><p><strong>sslcert</strong> - Path to client certificate to authenticate when SSL is used.</p></li>
<li><p><strong>sslkey</strong> - Path to client private key to authenticate when SSL is used.</p></li>
<li><p><strong>sslrootcert</strong> - Path to server’s certificate to authenticate when SSL is used.</p></li>
</ul>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>gcp_cloudsql_conn_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – URL of the connection</p></li>
<li><p><strong>gcp_conn_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – The connection ID used to connect to Google Cloud Platform for
cloud-sql-proxy authentication.</p></li>
<li><p><strong>default_gcp_project_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – Default project id used if project_id not specified
in the connection URL</p></li>
</ul>
</dd>
</dl>
<dl class="attribute">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook._conn">
<code class="sig-name descname">_conn</code><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlDatabaseHook._conn"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook._conn" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook._get_bool">
<em class="property">static </em><code class="sig-name descname">_get_bool</code><span class="sig-paren">(</span><em class="sig-param">val</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlDatabaseHook._get_bool"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook._get_bool" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook._check_ssl_file">
<em class="property">static </em><code class="sig-name descname">_check_ssl_file</code><span class="sig-paren">(</span><em class="sig-param">file_to_check</em>, <em class="sig-param">name</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlDatabaseHook._check_ssl_file"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook._check_ssl_file" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook._validate_inputs">
<code class="sig-name descname">_validate_inputs</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlDatabaseHook._validate_inputs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook._validate_inputs" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook.validate_ssl_certs">
<code class="sig-name descname">validate_ssl_certs</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlDatabaseHook.validate_ssl_certs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook.validate_ssl_certs" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook.validate_socket_path_length">
<code class="sig-name descname">validate_socket_path_length</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlDatabaseHook.validate_socket_path_length"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook.validate_socket_path_length" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook._generate_unique_path">
<em class="property">static </em><code class="sig-name descname">_generate_unique_path</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlDatabaseHook._generate_unique_path"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook._generate_unique_path" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook._quote">
<em class="property">static </em><code class="sig-name descname">_quote</code><span class="sig-paren">(</span><em class="sig-param">value</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlDatabaseHook._quote"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook._quote" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook._generate_connection_uri">
<code class="sig-name descname">_generate_connection_uri</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlDatabaseHook._generate_connection_uri"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook._generate_connection_uri" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook._get_instance_socket_name">
<code class="sig-name descname">_get_instance_socket_name</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlDatabaseHook._get_instance_socket_name"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook._get_instance_socket_name" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook._get_sqlproxy_instance_specification">
<code class="sig-name descname">_get_sqlproxy_instance_specification</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlDatabaseHook._get_sqlproxy_instance_specification"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook._get_sqlproxy_instance_specification" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook.create_connection">
<code class="sig-name descname">create_connection</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">session=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlDatabaseHook.create_connection"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook.create_connection" title="Permalink to this definition"></a></dt>
<dd><p>Create connection in the Connection table, according to whether it uses
proxy, TCP, UNIX sockets, SSL. Connection ID will be randomly generated.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>session</strong> – Session of the SQL Alchemy ORM (automatically generated with
decorator).</p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook.retrieve_connection">
<code class="sig-name descname">retrieve_connection</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">session=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlDatabaseHook.retrieve_connection"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook.retrieve_connection" title="Permalink to this definition"></a></dt>
<dd><p>Retrieves the dynamically created connection from the Connection table.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>session</strong> – Session of the SQL Alchemy ORM (automatically generated with
decorator).</p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook.delete_connection">
<code class="sig-name descname">delete_connection</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">session=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlDatabaseHook.delete_connection"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook.delete_connection" title="Permalink to this definition"></a></dt>
<dd><p>Delete the dynamically created connection from the Connection table.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>session</strong> – Session of the SQL Alchemy ORM (automatically generated with
decorator).</p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook.get_sqlproxy_runner">
<code class="sig-name descname">get_sqlproxy_runner</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlDatabaseHook.get_sqlproxy_runner"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook.get_sqlproxy_runner" title="Permalink to this definition"></a></dt>
<dd><p>Retrieve Cloud SQL Proxy runner. It is used to manage the proxy
lifecycle per task.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>The Cloud SQL Proxy runner.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><a class="reference internal" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlProxyRunner" title="airflow.contrib.hooks.gcp_sql_hook.CloudSqlProxyRunner">CloudSqlProxyRunner</a></p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook.get_database_hook">
<code class="sig-name descname">get_database_hook</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlDatabaseHook.get_database_hook"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook.get_database_hook" title="Permalink to this definition"></a></dt>
<dd><p>Retrieve database hook. This is the actual Postgres or MySQL database hook
that uses proxy or connects directly to the Google Cloud SQL database.</p>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook.cleanup_database_hook">
<code class="sig-name descname">cleanup_database_hook</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlDatabaseHook.cleanup_database_hook"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook.cleanup_database_hook" title="Permalink to this definition"></a></dt>
<dd><p>Clean up database hook after it was used.</p>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook.reserve_free_tcp_port">
<code class="sig-name descname">reserve_free_tcp_port</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlDatabaseHook.reserve_free_tcp_port"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook.reserve_free_tcp_port" title="Permalink to this definition"></a></dt>
<dd><p>Reserve free TCP port to be used by Cloud SQL Proxy</p>
</dd></dl>
<dl class="method">
<dt id="airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook.free_reserved_port">
<code class="sig-name descname">free_reserved_port</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="../../../../../_modules/airflow/contrib/hooks/gcp_sql_hook.html#CloudSqlDatabaseHook.free_reserved_port"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#airflow.contrib.hooks.gcp_sql_hook.CloudSqlDatabaseHook.free_reserved_port" title="Permalink to this definition"></a></dt>
<dd><p>Free TCP port. Makes it immediately ready to be used by Cloud SQL Proxy.</p>
</dd></dl>
</dd></dl>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="../gcp_text_to_speech_hook/index.html" class="btn btn-neutral float-right" title="airflow.contrib.hooks.gcp_text_to_speech_hook" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="../gcp_speech_to_text_hook/index.html" class="btn btn-neutral float-left" title="airflow.contrib.hooks.gcp_speech_to_text_hook" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>