This file is indexed.

/usr/share/doc/python3-postgresql/html/clientparameters.html is in python3-postgresql 1.1.0-2build2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
<!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>Client Parameters &mdash; py-postgresql 1.1.0 documentation</title>
    
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '1.1.0',
        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="py-postgresql 1.1.0 documentation" href="index.html" />
    <link rel="next" title="Gotchas" href="gotchas.html" />
    <link rel="prev" title="Categories and Libraries" href="lib.html" />

   
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9">

<link rel="stylesheet" href="_static/unsuck.css" type="text/css" />

  </head>
  <body role="document">  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="client-parameters">
<h1>Client Parameters<a class="headerlink" href="#client-parameters" title="Permalink to this headline"></a></h1>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last"><strong>The interfaces dealing with optparse are subject to change in 1.0</strong>.</p>
</div>
<p>There are various sources of parameters used by PostgreSQL client applications.
The <cite>postgresql.clientparameters</cite> module provides a means for collecting and
managing those parameters.</p>
<p>Connection creation interfaces in <cite>postgresql.driver</cite> are purposefully simple.
All parameters taken by those interfaces are keywords, and are taken
literally; if a parameter is not given, it will effectively be <cite>None</cite>.
libpq-based drivers tend differ as they inherit some default client parameters
from the environment. Doing this by default is undesirable as it can cause
trivial failures due to unexpected parameter inheritance. However, using these
parameters from the environment and other sources are simply expected in <em>some</em>
cases: <cite>postgresql.open</cite>, <cite>postgresql.bin.pg_python</cite>, and other high-level
utilities. The <cite>postgresql.clientparameters</cite> module provides a means to collect
them into one dictionary object for subsequent application to a connection
creation interface.</p>
<p><cite>postgresql.clientparameters</cite> is primarily useful to script authors that want to
provide an interface consistent with PostgreSQL commands like <code class="docutils literal"><span class="pre">psql</span></code>.</p>
<div class="section" id="collecting-parameters">
<h2>Collecting Parameters<a class="headerlink" href="#collecting-parameters" title="Permalink to this headline"></a></h2>
<p>The primary entry points in <cite>postgresql.clientparameters</cite> are
<cite>postgresql.clientparameters.collect</cite> and
<cite>postgresql.clientparameters.resolve_password</cite>.</p>
<p>For most purposes, <code class="docutils literal"><span class="pre">collect</span></code> will suffice. By default, it will prompt for the
password if instructed to(<code class="docutils literal"><span class="pre">-W</span></code>). Therefore, <code class="docutils literal"><span class="pre">resolve_password</span></code> need not be
used in most cases:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">sys</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">postgresql.clientparameters</span> <span class="kn">as</span> <span class="nn">pg_param</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">pg_param</span><span class="o">.</span><span class="n">DefaultParser</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">co</span><span class="p">,</span> <span class="n">ca</span> <span class="o">=</span> <span class="n">p</span><span class="o">.</span><span class="n">parse_args</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">:])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">params</span> <span class="o">=</span> <span class="n">pg_param</span><span class="o">.</span><span class="n">collect</span><span class="p">(</span><span class="n">parsed_options</span> <span class="o">=</span> <span class="n">co</span><span class="p">)</span>
</pre></div>
</div>
<p>The <cite>postgresql.clientparameters</cite> module is executable, so you can see the
results of the above snippet by:</p>
<div class="highlight-python"><div class="highlight"><pre>$ python -m postgresql.clientparameters -h localhost -U a_db_user -ssearch_path=public
{&#39;host&#39;: &#39;localhost&#39;,
 &#39;password&#39;: None,
 &#39;port&#39;: 5432,
 &#39;settings&#39;: {&#39;search_path&#39;: &#39;public&#39;},
 &#39;user&#39;: &#39;a_db_user&#39;}
</pre></div>
</div>
<div class="section" id="postgresql-clientparameters-collect">
<h3><cite>postgresql.clientparameters.collect</cite><a class="headerlink" href="#postgresql-clientparameters-collect" title="Permalink to this headline"></a></h3>
<p>Build a client parameter dictionary from the environment and parsed command
line options. The following is a list of keyword arguments that <code class="docutils literal"><span class="pre">collect</span></code> will
accept:</p>
<blockquote>
<div><dl class="docutils">
<dt><code class="docutils literal"><span class="pre">parsed_options</span></code></dt>
<dd>Options parsed by <cite>postgresql.clientparameters.StandardParser</cite> or
<cite>postgresql.clientparameters.DefaultParser</cite> instances.</dd>
<dt><code class="docutils literal"><span class="pre">no_defaults</span></code></dt>
<dd>When <cite>True</cite>, don&#8217;t include defaults like <code class="docutils literal"><span class="pre">pgpassfile</span></code> and <code class="docutils literal"><span class="pre">user</span></code>.
Defaults to <cite>False</cite>.</dd>
<dt><code class="docutils literal"><span class="pre">environ</span></code></dt>
<dd>Environment variables to extract client parameter variables from.
Defaults to <cite>os.environ</cite> and expects a <cite>collections.Mapping</cite> interface.</dd>
<dt><code class="docutils literal"><span class="pre">environ_prefix</span></code></dt>
<dd>Environment variable prefix to use. Defaults to &#8220;PG&#8221;. This allows the
collection of non-standard environment variables whose keys are partially
consistent with the standard variants. e.g. &#8220;PG_SRC_USER&#8221;, &#8220;PG_SRC_HOST&#8221;,
etc.</dd>
<dt><code class="docutils literal"><span class="pre">default_pg_sysconfdir</span></code></dt>
<dd>The location of the pg_service.conf file. The <code class="docutils literal"><span class="pre">PGSYSCONFDIR</span></code> environment
variable will override this. When a default installation is present,
<code class="docutils literal"><span class="pre">PGINSTALLATION</span></code>, it should be set to this.</dd>
<dt><code class="docutils literal"><span class="pre">pg_service_file</span></code></dt>
<dd>Explicit location of the service file. This will override the &#8220;sysconfdir&#8221;
based path.</dd>
<dt><code class="docutils literal"><span class="pre">prompt_title</span></code></dt>
<dd>Descriptive title to use if a password prompt is needed. <cite>None</cite> to disable
password resolution entirely. Setting this to <cite>None</cite> will also disable
pgpassfile lookups, so it is necessary that further processing occurs when
this is <cite>None</cite>.</dd>
<dt><code class="docutils literal"><span class="pre">parameters</span></code></dt>
<dd>Base client parameters to use. These are set after the <em>defaults</em> are
collected. (The defaults that can be disabled by <code class="docutils literal"><span class="pre">no_defaults</span></code>).</dd>
</dl>
</div></blockquote>
<p>If <code class="docutils literal"><span class="pre">prompt_title</span></code> is not set to <cite>None</cite>, it will prompt for the password when
instructed to do by the <code class="docutils literal"><span class="pre">prompt_password</span></code> key in the parameters:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">postgresql.clientparameters</span> <span class="kn">as</span> <span class="nn">pg_param</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">pg_param</span><span class="o">.</span><span class="n">collect</span><span class="p">(</span><span class="n">prompt_title</span> <span class="o">=</span> <span class="s">&#39;my_prompt!&#39;</span><span class="p">,</span> <span class="n">parameters</span> <span class="o">=</span> <span class="p">{</span><span class="s">&#39;prompt_password&#39;</span><span class="p">:</span><span class="bp">True</span><span class="p">})</span>
<span class="go">Password for my_prompt![pq://jwp@localhost:5432]:</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span>
<span class="go">{&#39;host&#39;: &#39;localhost&#39;, &#39;user&#39;: &#39;jwp&#39;, &#39;password&#39;: &#39;secret&#39;, &#39;port&#39;: 5432}</span>
</pre></div>
</div>
<p>If <cite>None</cite>, it will leave the necessary password resolution information in the
parameters dictionary for <code class="docutils literal"><span class="pre">resolve_password</span></code>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">pg_param</span><span class="o">.</span><span class="n">collect</span><span class="p">(</span><span class="n">prompt_title</span> <span class="o">=</span> <span class="bp">None</span><span class="p">,</span> <span class="n">parameters</span> <span class="o">=</span> <span class="p">{</span><span class="s">&#39;prompt_password&#39;</span><span class="p">:</span><span class="bp">True</span><span class="p">})</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span>
<span class="go">{&#39;pgpassfile&#39;: &#39;/Users/jwp/.pgpass&#39;, &#39;prompt_password&#39;: True, &#39;host&#39;: &#39;localhost&#39;, &#39;user&#39;: &#39;jwp&#39;, &#39;port&#39;: 5432}</span>
</pre></div>
</div>
<p>Of course, <code class="docutils literal"><span class="pre">'prompt_password'</span></code> is normally specified when <code class="docutils literal"><span class="pre">parsed_options</span></code>
received a <code class="docutils literal"><span class="pre">-W</span></code> option from the command line:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">op</span> <span class="o">=</span> <span class="n">pg_param</span><span class="o">.</span><span class="n">DefaultParser</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">co</span><span class="p">,</span> <span class="n">ca</span> <span class="o">=</span> <span class="n">op</span><span class="o">.</span><span class="n">parse_args</span><span class="p">([</span><span class="s">&#39;-W&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">pg_param</span><span class="o">.</span><span class="n">collect</span><span class="p">(</span><span class="n">parsed_options</span> <span class="o">=</span> <span class="n">co</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">=</span><span class="n">pg_param</span><span class="o">.</span><span class="n">collect</span><span class="p">(</span><span class="n">parsed_options</span> <span class="o">=</span> <span class="n">co</span><span class="p">)</span>
<span class="go">Password for [pq://jwp@localhost:5432]:</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span>
<span class="go">{&#39;host&#39;: &#39;localhost&#39;, &#39;user&#39;: &#39;jwp&#39;, &#39;password&#39;: &#39;secret&#39;, &#39;port&#39;: 5432}</span>
<span class="go">&gt;&gt;&gt;</span>
</pre></div>
</div>
</div>
<div class="section" id="postgresql-clientparameters-resolve-password">
<h3><cite>postgresql.clientparameters.resolve_password</cite><a class="headerlink" href="#postgresql-clientparameters-resolve-password" title="Permalink to this headline"></a></h3>
<p>Resolve the password for the given client parameters dictionary returned by
<code class="docutils literal"><span class="pre">collect</span></code>. By default, this function need not be used as <code class="docutils literal"><span class="pre">collect</span></code> will
resolve the password by default. <cite>resolve_password</cite> accepts the following
arguments:</p>
<blockquote>
<div><dl class="docutils">
<dt><code class="docutils literal"><span class="pre">parameters</span></code></dt>
<dd>First positional argument. Normalized client parameters dictionary to update
in-place with the resolved password. If the &#8216;prompt_password&#8217; key is in
<code class="docutils literal"><span class="pre">parameters</span></code>, it will prompt regardless(normally comes from <code class="docutils literal"><span class="pre">-W</span></code>).</dd>
<dt><code class="docutils literal"><span class="pre">getpass</span></code></dt>
<dd>Function to call to prompt for the password. Defaults to <cite>getpass.getpass</cite>.</dd>
<dt><code class="docutils literal"><span class="pre">prompt_title</span></code></dt>
<dd>Additional title to use if a prompt is requested. This can also be specified
in the <code class="docutils literal"><span class="pre">parameters</span></code> as the <code class="docutils literal"><span class="pre">prompt_title</span></code> key. This <em>augments</em> the IRI
display on the prompt. Defaults to an empty string, <code class="docutils literal"><span class="pre">''</span></code>.</dd>
</dl>
</div></blockquote>
<p>The resolution process is effected by the contents of the given <code class="docutils literal"><span class="pre">parameters</span></code>.
Notable keywords:</p>
<blockquote>
<div><dl class="docutils">
<dt><code class="docutils literal"><span class="pre">prompt_password</span></code></dt>
<dd>If present in the given parameters, the user will be prompted for the using
the given <code class="docutils literal"><span class="pre">getpass</span></code> function. This disables the password file lookup
process.</dd>
<dt><code class="docutils literal"><span class="pre">prompt_title</span></code></dt>
<dd>This states a default prompt title to use. If the <code class="docutils literal"><span class="pre">prompt_title</span></code> keyword
argument is given to <code class="docutils literal"><span class="pre">resolve_password</span></code>, this will not be used.</dd>
<dt><code class="docutils literal"><span class="pre">pgpassfile</span></code></dt>
<dd>The PostgreSQL password file to lookup the password in. If the <code class="docutils literal"><span class="pre">password</span></code>
parameter is present, this will not be used.</dd>
</dl>
</div></blockquote>
<p>When resolution occurs, the <code class="docutils literal"><span class="pre">prompt_password</span></code>, <code class="docutils literal"><span class="pre">prompt_title</span></code>, and
<code class="docutils literal"><span class="pre">pgpassfile</span></code> keys are <em>removed</em> from the given parameters dictionary:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">=</span><span class="n">pg_param</span><span class="o">.</span><span class="n">collect</span><span class="p">(</span><span class="n">prompt_title</span> <span class="o">=</span> <span class="bp">None</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span>
<span class="go">{&#39;pgpassfile&#39;: &#39;/Users/jwp/.pgpass&#39;, &#39;host&#39;: &#39;localhost&#39;, &#39;user&#39;: &#39;jwp&#39;, &#39;port&#39;: 5432}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pg_param</span><span class="o">.</span><span class="n">resolve_password</span><span class="p">(</span><span class="n">p</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span>
<span class="go">{&#39;host&#39;: &#39;localhost&#39;, &#39;password&#39;: &#39;secret&#39;, &#39;user&#39;: &#39;jwp&#39;, &#39;port&#39;: 5432}</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="defaults">
<h2>Defaults<a class="headerlink" href="#defaults" title="Permalink to this headline"></a></h2>
<p>The following is a list of default parameters provided by <code class="docutils literal"><span class="pre">collect</span></code> and the
sources of their values:</p>
<blockquote>
<div><table border="1" class="docutils">
<colgroup>
<col width="23%" />
<col width="77%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Key</th>
<th class="head">Value</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">'user'</span></code></td>
<td><cite>getpass.getuser()</cite> or <code class="docutils literal"><span class="pre">'postgres'</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">'host'</span></code></td>
<td><cite>postgresql.clientparameters.default_host</cite> (<code class="docutils literal"><span class="pre">'localhost'</span></code>)</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">'port'</span></code></td>
<td><cite>postgresql.clientparameters.default_port</cite> (<code class="docutils literal"><span class="pre">5432</span></code>)</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">'pgpassfile'</span></code></td>
<td><code class="docutils literal"><span class="pre">&quot;$HOME/.pgpassfile&quot;</span></code> or <code class="docutils literal"><span class="pre">[PGDATA]</span></code> + <code class="docutils literal"><span class="pre">'pgpass.conf'</span></code> (Win32)</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">'sslcrtfile'</span></code></td>
<td><code class="docutils literal"><span class="pre">[PGDATA]</span></code> + <code class="docutils literal"><span class="pre">'postgresql.crt'</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">'sslkeyfile'</span></code></td>
<td><code class="docutils literal"><span class="pre">[PGDATA]</span></code> + <code class="docutils literal"><span class="pre">'postgresql.key'</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">'sslrootcrtfile'</span></code></td>
<td><code class="docutils literal"><span class="pre">[PGDATA]</span></code> + <code class="docutils literal"><span class="pre">'root.crt'</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">'sslrootcrlfile'</span></code></td>
<td><code class="docutils literal"><span class="pre">[PGDATA]</span></code> + <code class="docutils literal"><span class="pre">'root.crl'</span></code></td>
</tr>
</tbody>
</table>
</div></blockquote>
<p><code class="docutils literal"><span class="pre">[PGDATA]</span></code> referenced in the above table is a directory whose path is platform
dependent. On most systems, it is <code class="docutils literal"><span class="pre">&quot;$HOME/.postgresql&quot;</span></code>, but on Windows based
systems it is <code class="docutils literal"><span class="pre">&quot;%APPDATA%\postgresql&quot;</span></code></p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">[PGDATA] is <em>not</em> an environment variable.</p>
</div>
</div>
<div class="section" id="postgresql-environment-variables">
<span id="pg-envvars"></span><h2>PostgreSQL Environment Variables<a class="headerlink" href="#postgresql-environment-variables" title="Permalink to this headline"></a></h2>
<p>The following is a list of environment variables that will be collected by the
<cite>postgresql.clientparameter.collect</cite> function using &#8220;PG&#8221; as the
<code class="docutils literal"><span class="pre">environ_prefix</span></code> and the keyword that it will be mapped to:</p>
<blockquote>
<div><table border="1" class="docutils">
<colgroup>
<col width="36%" />
<col width="64%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Environment Variable</th>
<th class="head">Keyword</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">PGUSER</span></code></td>
<td><code class="docutils literal"><span class="pre">'user'</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">PGDATABASE</span></code></td>
<td><code class="docutils literal"><span class="pre">'database'</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">PGHOST</span></code></td>
<td><code class="docutils literal"><span class="pre">'host'</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">PGPORT</span></code></td>
<td><code class="docutils literal"><span class="pre">'port'</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">PGPASSWORD</span></code></td>
<td><code class="docutils literal"><span class="pre">'password'</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">PGSSLMODE</span></code></td>
<td><code class="docutils literal"><span class="pre">'sslmode'</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">PGSSLKEY</span></code></td>
<td><code class="docutils literal"><span class="pre">'sslkey'</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">PGCONNECT_TIMEOUT</span></code></td>
<td><code class="docutils literal"><span class="pre">'connect_timeout'</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">PGREALM</span></code></td>
<td><code class="docutils literal"><span class="pre">'kerberos4_realm'</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">PGKRBSRVNAME</span></code></td>
<td><code class="docutils literal"><span class="pre">'kerberos5_service'</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">PGPASSFILE</span></code></td>
<td><code class="docutils literal"><span class="pre">'pgpassfile'</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">PGTZ</span></code></td>
<td><code class="docutils literal"><span class="pre">'settings'</span> <span class="pre">=</span> <span class="pre">{'timezone':</span> <span class="pre">}</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">PGDATESTYLE</span></code></td>
<td><code class="docutils literal"><span class="pre">'settings'</span> <span class="pre">=</span> <span class="pre">{'datestyle':</span> <span class="pre">}</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">PGCLIENTENCODING</span></code></td>
<td><code class="docutils literal"><span class="pre">'settings'</span> <span class="pre">=</span> <span class="pre">{'client_encoding':</span> <span class="pre">}</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">PGGEQO</span></code></td>
<td><code class="docutils literal"><span class="pre">'settings'</span> <span class="pre">=</span> <span class="pre">{'geqo':</span> <span class="pre">}</span></code></td>
</tr>
</tbody>
</table>
</div></blockquote>
</div>
<div class="section" id="postgresql-password-file">
<span id="pg-passfile"></span><h2>PostgreSQL Password File<a class="headerlink" href="#postgresql-password-file" title="Permalink to this headline"></a></h2>
<p>The password file is a simple newline separated list of <code class="docutils literal"><span class="pre">:</span></code> separated fields. It
is located at <code class="docutils literal"><span class="pre">$HOME/.pgpass</span></code> for most systems and at
<code class="docutils literal"><span class="pre">%APPDATA%\postgresql\pgpass.conf</span></code> for Windows based systems. However, the
<code class="docutils literal"><span class="pre">PGPASSFILE</span></code> environment variable may be used to override that location.</p>
<p>The lines in the file must be in the following form:</p>
<div class="highlight-python"><div class="highlight"><pre>hostname:port:database:username:password
</pre></div>
</div>
<p>A single asterisk, <code class="docutils literal"><span class="pre">*</span></code>, may be used to indicate that any value will match the
field. However, this only effects fields other than <code class="docutils literal"><span class="pre">password</span></code>.</p>
<p>See <a class="reference external" href="http://www.postgresql.org/docs/current/static/libpq-pgpass.html">http://www.postgresql.org/docs/current/static/libpq-pgpass.html</a> for more
details.</p>
<p>Client parameters produced by <code class="docutils literal"><span class="pre">collect</span></code> that have not been processed
by <code class="docutils literal"><span class="pre">resolve_password</span></code> will include a <code class="docutils literal"><span class="pre">'pgpassfile'</span></code> key. This is the value
that <code class="docutils literal"><span class="pre">resolve_password</span></code> will use to locate the pgpassfile to interrogate if a
password key is not present and it is not instructed to prompt for a password.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">Connection creation interfaces will <em>not</em> resolve <code class="docutils literal"><span class="pre">'pgpassfile'</span></code>, so it is
important that the parameters produced by <code class="docutils literal"><span class="pre">collect()</span></code> are properly processed
before an attempt is made to establish a connection.</p>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Client Parameters</a><ul>
<li><a class="reference internal" href="#collecting-parameters">Collecting Parameters</a><ul>
<li><a class="reference internal" href="#postgresql-clientparameters-collect"><cite>postgresql.clientparameters.collect</cite></a></li>
<li><a class="reference internal" href="#postgresql-clientparameters-resolve-password"><cite>postgresql.clientparameters.resolve_password</cite></a></li>
</ul>
</li>
<li><a class="reference internal" href="#defaults">Defaults</a></li>
<li><a class="reference internal" href="#postgresql-environment-variables">PostgreSQL Environment Variables</a></li>
<li><a class="reference internal" href="#postgresql-password-file">PostgreSQL Password File</a></li>
</ul>
</li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
  <li><a href="index.html">Documentation overview</a><ul>
      <li>Previous: <a href="lib.html" title="previous chapter">Categories and Libraries</a></li>
      <li>Next: <a href="gotchas.html" title="next chapter">Gotchas</a></li>
  </ul></li>
</ul>
</div>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="_sources/clientparameters.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="footer">
      &copy;Python+Postgres.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 1.3.4</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.6</a>
      
      |
      <a href="_sources/clientparameters.txt"
          rel="nofollow">Page source</a>
    </div>

    

    
  </body>
</html>