This file is indexed.

/usr/share/doc/python3-postgresql/html/clientparameters.html is in python3-postgresql 1.1.0-1build1.

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
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
<!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" />
 
<link rel="stylesheet" href="_static/unsuck.css" type="text/css" />

  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="gotchas.html" title="Gotchas"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="lib.html" title="Categories and Libraries"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">py-postgresql 1.1.0 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <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 <tt class="docutils literal"><span class="pre">psql</span></tt>.</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, <tt class="docutils literal"><span class="pre">collect</span></tt> will suffice. By default, it will prompt for the
password if instructed to(<tt class="docutils literal"><span class="pre">-W</span></tt>). Therefore, <tt class="docutils literal"><span class="pre">resolve_password</span></tt> 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 <tt class="docutils literal"><span class="pre">collect</span></tt> will
accept:</p>
<blockquote>
<div><dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">parsed_options</span></tt></dt>
<dd>Options parsed by <cite>postgresql.clientparameters.StandardParser</cite> or
<cite>postgresql.clientparameters.DefaultParser</cite> instances.</dd>
<dt><tt class="docutils literal"><span class="pre">no_defaults</span></tt></dt>
<dd>When <cite>True</cite>, don&#8217;t include defaults like <tt class="docutils literal"><span class="pre">pgpassfile</span></tt> and <tt class="docutils literal"><span class="pre">user</span></tt>.
Defaults to <cite>False</cite>.</dd>
<dt><tt class="docutils literal"><span class="pre">environ</span></tt></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><tt class="docutils literal"><span class="pre">environ_prefix</span></tt></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><tt class="docutils literal"><span class="pre">default_pg_sysconfdir</span></tt></dt>
<dd>The location of the pg_service.conf file. The <tt class="docutils literal"><span class="pre">PGSYSCONFDIR</span></tt> environment
variable will override this. When a default installation is present,
<tt class="docutils literal"><span class="pre">PGINSTALLATION</span></tt>, it should be set to this.</dd>
<dt><tt class="docutils literal"><span class="pre">pg_service_file</span></tt></dt>
<dd>Explicit location of the service file. This will override the &#8220;sysconfdir&#8221;
based path.</dd>
<dt><tt class="docutils literal"><span class="pre">prompt_title</span></tt></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><tt class="docutils literal"><span class="pre">parameters</span></tt></dt>
<dd>Base client parameters to use. These are set after the <em>defaults</em> are
collected. (The defaults that can be disabled by <tt class="docutils literal"><span class="pre">no_defaults</span></tt>).</dd>
</dl>
</div></blockquote>
<p>If <tt class="docutils literal"><span class="pre">prompt_title</span></tt> is not set to <cite>None</cite>, it will prompt for the password when
instructed to do by the <tt class="docutils literal"><span class="pre">prompt_password</span></tt> 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 <tt class="docutils literal"><span class="pre">resolve_password</span></tt>:</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, <tt class="docutils literal"><span class="pre">'prompt_password'</span></tt> is normally specified when <tt class="docutils literal"><span class="pre">parsed_options</span></tt>
received a <tt class="docutils literal"><span class="pre">-W</span></tt> 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
<tt class="docutils literal"><span class="pre">collect</span></tt>. By default, this function need not be used as <tt class="docutils literal"><span class="pre">collect</span></tt> will
resolve the password by default. <cite>resolve_password</cite> accepts the following
arguments:</p>
<blockquote>
<div><dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">parameters</span></tt></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
<tt class="docutils literal"><span class="pre">parameters</span></tt>, it will prompt regardless(normally comes from <tt class="docutils literal"><span class="pre">-W</span></tt>).</dd>
<dt><tt class="docutils literal"><span class="pre">getpass</span></tt></dt>
<dd>Function to call to prompt for the password. Defaults to <cite>getpass.getpass</cite>.</dd>
<dt><tt class="docutils literal"><span class="pre">prompt_title</span></tt></dt>
<dd>Additional title to use if a prompt is requested. This can also be specified
in the <tt class="docutils literal"><span class="pre">parameters</span></tt> as the <tt class="docutils literal"><span class="pre">prompt_title</span></tt> key. This <em>augments</em> the IRI
display on the prompt. Defaults to an empty string, <tt class="docutils literal"><span class="pre">''</span></tt>.</dd>
</dl>
</div></blockquote>
<p>The resolution process is effected by the contents of the given <tt class="docutils literal"><span class="pre">parameters</span></tt>.
Notable keywords:</p>
<blockquote>
<div><dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">prompt_password</span></tt></dt>
<dd>If present in the given parameters, the user will be prompted for the using
the given <tt class="docutils literal"><span class="pre">getpass</span></tt> function. This disables the password file lookup
process.</dd>
<dt><tt class="docutils literal"><span class="pre">prompt_title</span></tt></dt>
<dd>This states a default prompt title to use. If the <tt class="docutils literal"><span class="pre">prompt_title</span></tt> keyword
argument is given to <tt class="docutils literal"><span class="pre">resolve_password</span></tt>, this will not be used.</dd>
<dt><tt class="docutils literal"><span class="pre">pgpassfile</span></tt></dt>
<dd>The PostgreSQL password file to lookup the password in. If the <tt class="docutils literal"><span class="pre">password</span></tt>
parameter is present, this will not be used.</dd>
</dl>
</div></blockquote>
<p>When resolution occurs, the <tt class="docutils literal"><span class="pre">prompt_password</span></tt>, <tt class="docutils literal"><span class="pre">prompt_title</span></tt>, and
<tt class="docutils literal"><span class="pre">pgpassfile</span></tt> 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 <tt class="docutils literal"><span class="pre">collect</span></tt> 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><tt class="docutils literal"><span class="pre">'user'</span></tt></td>
<td><cite>getpass.getuser()</cite> or <tt class="docutils literal"><span class="pre">'postgres'</span></tt></td>
</tr>
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">'host'</span></tt></td>
<td><cite>postgresql.clientparameters.default_host</cite> (<tt class="docutils literal"><span class="pre">'localhost'</span></tt>)</td>
</tr>
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">'port'</span></tt></td>
<td><cite>postgresql.clientparameters.default_port</cite> (<tt class="docutils literal"><span class="pre">5432</span></tt>)</td>
</tr>
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">'pgpassfile'</span></tt></td>
<td><tt class="docutils literal"><span class="pre">&quot;$HOME/.pgpassfile&quot;</span></tt> or <tt class="docutils literal"><span class="pre">[PGDATA]</span></tt> + <tt class="docutils literal"><span class="pre">'pgpass.conf'</span></tt> (Win32)</td>
</tr>
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">'sslcrtfile'</span></tt></td>
<td><tt class="docutils literal"><span class="pre">[PGDATA]</span></tt> + <tt class="docutils literal"><span class="pre">'postgresql.crt'</span></tt></td>
</tr>
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">'sslkeyfile'</span></tt></td>
<td><tt class="docutils literal"><span class="pre">[PGDATA]</span></tt> + <tt class="docutils literal"><span class="pre">'postgresql.key'</span></tt></td>
</tr>
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">'sslrootcrtfile'</span></tt></td>
<td><tt class="docutils literal"><span class="pre">[PGDATA]</span></tt> + <tt class="docutils literal"><span class="pre">'root.crt'</span></tt></td>
</tr>
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">'sslrootcrlfile'</span></tt></td>
<td><tt class="docutils literal"><span class="pre">[PGDATA]</span></tt> + <tt class="docutils literal"><span class="pre">'root.crl'</span></tt></td>
</tr>
</tbody>
</table>
</div></blockquote>
<p><tt class="docutils literal"><span class="pre">[PGDATA]</span></tt> referenced in the above table is a directory whose path is platform
dependent. On most systems, it is <tt class="docutils literal"><span class="pre">&quot;$HOME/.postgresql&quot;</span></tt>, but on Windows based
systems it is <tt class="docutils literal"><span class="pre">&quot;%APPDATA%\postgresql&quot;</span></tt></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
<tt class="docutils literal"><span class="pre">environ_prefix</span></tt> 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><tt class="docutils literal"><span class="pre">PGUSER</span></tt></td>
<td><tt class="docutils literal"><span class="pre">'user'</span></tt></td>
</tr>
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">PGDATABASE</span></tt></td>
<td><tt class="docutils literal"><span class="pre">'database'</span></tt></td>
</tr>
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">PGHOST</span></tt></td>
<td><tt class="docutils literal"><span class="pre">'host'</span></tt></td>
</tr>
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">PGPORT</span></tt></td>
<td><tt class="docutils literal"><span class="pre">'port'</span></tt></td>
</tr>
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">PGPASSWORD</span></tt></td>
<td><tt class="docutils literal"><span class="pre">'password'</span></tt></td>
</tr>
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">PGSSLMODE</span></tt></td>
<td><tt class="docutils literal"><span class="pre">'sslmode'</span></tt></td>
</tr>
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">PGSSLKEY</span></tt></td>
<td><tt class="docutils literal"><span class="pre">'sslkey'</span></tt></td>
</tr>
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">PGCONNECT_TIMEOUT</span></tt></td>
<td><tt class="docutils literal"><span class="pre">'connect_timeout'</span></tt></td>
</tr>
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">PGREALM</span></tt></td>
<td><tt class="docutils literal"><span class="pre">'kerberos4_realm'</span></tt></td>
</tr>
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">PGKRBSRVNAME</span></tt></td>
<td><tt class="docutils literal"><span class="pre">'kerberos5_service'</span></tt></td>
</tr>
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">PGPASSFILE</span></tt></td>
<td><tt class="docutils literal"><span class="pre">'pgpassfile'</span></tt></td>
</tr>
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">PGTZ</span></tt></td>
<td><tt class="docutils literal"><span class="pre">'settings'</span> <span class="pre">=</span> <span class="pre">{'timezone':</span> <span class="pre">}</span></tt></td>
</tr>
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">PGDATESTYLE</span></tt></td>
<td><tt class="docutils literal"><span class="pre">'settings'</span> <span class="pre">=</span> <span class="pre">{'datestyle':</span> <span class="pre">}</span></tt></td>
</tr>
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">PGCLIENTENCODING</span></tt></td>
<td><tt class="docutils literal"><span class="pre">'settings'</span> <span class="pre">=</span> <span class="pre">{'client_encoding':</span> <span class="pre">}</span></tt></td>
</tr>
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">PGGEQO</span></tt></td>
<td><tt class="docutils literal"><span class="pre">'settings'</span> <span class="pre">=</span> <span class="pre">{'geqo':</span> <span class="pre">}</span></tt></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 <tt class="docutils literal"><span class="pre">:</span></tt> separated fields. It
is located at <tt class="docutils literal"><span class="pre">$HOME/.pgpass</span></tt> for most systems and at
<tt class="docutils literal"><span class="pre">%APPDATA%\postgresql\pgpass.conf</span></tt> for Windows based systems. However, the
<tt class="docutils literal"><span class="pre">PGPASSFILE</span></tt> 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, <tt class="docutils literal"><span class="pre">*</span></tt>, may be used to indicate that any value will match the
field. However, this only effects fields other than <tt class="docutils literal"><span class="pre">password</span></tt>.</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 <tt class="docutils literal"><span class="pre">collect</span></tt> that have not been processed
by <tt class="docutils literal"><span class="pre">resolve_password</span></tt> will include a <tt class="docutils literal"><span class="pre">'pgpassfile'</span></tt> key. This is the value
that <tt class="docutils literal"><span class="pre">resolve_password</span></tt> 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 <tt class="docutils literal"><span class="pre">'pgpassfile'</span></tt>, so it is
important that the parameters produced by <tt class="docutils literal"><span class="pre">collect()</span></tt> are properly processed
before an attempt is made to establish a connection.</p>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <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>

  <h4>Previous topic</h4>
  <p class="topless"><a href="lib.html"
                        title="previous chapter">Categories and Libraries</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="gotchas.html"
                        title="next chapter">Gotchas</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/clientparameters.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="gotchas.html" title="Gotchas"
             >next</a> |</li>
        <li class="right" >
          <a href="lib.html" title="Categories and Libraries"
             >previous</a> |</li>
        <li><a href="index.html">py-postgresql 1.1.0 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright Python+Postgres.
      Last updated on Mar 31, 2014.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
    </div>
  </body>
</html>