Changeset 992 for trunk


Ignore:
Timestamp:
Apr 24, 2019, 4:16:19 PM (3 months ago)
Author:
cito
Message:

Document how to send more parameters with connect

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/contents/pg/module.rst

    r980 r992  
    4747PostgreSQL server. You can use keywords here, as described in the
    4848Python tutorial. The names of the keywords are the name of the
    49 parameters given in the syntax line. For a precise description
     49parameters given in the syntax line. The ``opt`` parameter can be used
     50to pass command-line options to the server. For a precise description
    5051of the parameters, please refer to the PostgreSQL user manual.
    5152
     53If you want to add additional parameters not specified here, you must
     54pass a connection string or a connection URI instead of the ``dbname``
     55(as in ``con3`` and ``con4``  in the following example).
     56
    5257Example::
    5358
    5459    import pg
    5560
    56     con1 = pg.connect('testdb', 'myhost', 5432, None, None, 'bob', None)
    57     con2 = pg.connect(dbname='testdb', host='localhost', user='bob')
     61    con1 = pg.connect('testdb', 'myhost', 5432, None, 'bob', None)
     62    con2 = pg.connect(dbname='testdb', host='myhost', user='bob')
     63    con3 = pg.connect('host=myhost user=bob dbname=testdb connect_timeout=10')
     64    con4 = pg.connect('postgresql://bob@myhost/testdb?connect_timeout=10')
    5865
    5966get/set_defhost -- default server host [DV]
Note: See TracChangeset for help on using the changeset viewer.