Skip to content

Commit 11d3bac

Browse files
author
James William Pye
committed
Allow prompt_title to be given on open() and dbapi.connect()
1 parent e16074f commit 11d3bac

3 files changed

Lines changed: 5 additions & 9 deletions

File tree

postgresql/__init__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
)
3333

3434
pg_iri = pg_driver = pg_param = None
35-
def open(iri = None, **kw):
35+
def open(iri = None, prompt_title = None, **kw):
3636
"""
3737
Create a `postgresql.api.Connection` to the server referenced by the given
3838
`iri`::
@@ -44,9 +44,6 @@ def open(iri = None, **kw):
4444
# Connect to 'postgres' at localhost.
4545
>>> db = postgresql.open('localhost/postgres')
4646
47-
If the URL starts with an '&', a connector will be returned instead of a
48-
connection.
49-
5047
(Note: "pq" is the name of the protocol used to communicate with PostgreSQL)
5148
"""
5249
global pg_iri, pg_driver, pg_param
@@ -72,7 +69,7 @@ def open(iri = None, **kw):
7269
list(pg_param.denormalize_parameters(kw))
7370
)
7471
# Resolve the password, but never prompt.
75-
pg_param.resolve_password(params, prompt_title = None)
72+
pg_param.resolve_password(params, prompt_title = prompt_title)
7673

7774
C = pg_driver.default.fit(**params)
7875
if return_connector is True:

postgresql/driver/dbapi20.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def rollback(self):
375375
self._xact.start()
376376

377377
driver = pg_driver.Driver(connection = Connection)
378-
def connect(**kw):
378+
def connect(prompt_title = None, **kw):
379379
"""
380380
Create a DB-API connection using the given parameters.
381381
"""
@@ -385,5 +385,5 @@ def connect(**kw):
385385
list(pg_param.denormalize_parameters(kw))
386386
)
387387
# Resolve the password, but never prompt.
388-
pg_param.resolve_password(params, prompt_title = None)
388+
pg_param.resolve_password(params, prompt_title = prompt_title)
389389
return driver.connect(**params)

postgresql/driver/pq3.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from abc import abstractmethod, abstractproperty
2525

2626
from .. import lib as pg_lib
27-
from ..lib import sys as pg_sys
2827

2928
from .. import versionstring as pg_version
3029
from .. import iri as pg_iri
@@ -1919,7 +1918,7 @@ def connect(self):
19191918
),
19201919
)
19211920
# manual binding
1922-
self.sys = pg_lib.Binding(self, pg_sys)
1921+
self.sys = pg_lib.Binding(self, pg_lib.sys)
19231922

19241923
# Get the *full* version string.
19251924
self.version = self.prepare("SELECT pg_catalog.version()").first()

0 commit comments

Comments
 (0)