Skip to content

Commit 03703af

Browse files
author
James William Pye
committed
Rename pgapi to pq3.
That is, py-postgresql is PG-API. This module's name marks that the implementation is for PQ 3.0
1 parent 8c344b5 commit 03703af

3 files changed

Lines changed: 9 additions & 23 deletions

File tree

postgresql/driver/__init__.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,9 @@
55
"""
66
Driver package for connecting to PostgreSQL via a data stream(sockets).
77
"""
8-
from . import pgapi as implementation
98
__all__ = ['Connector', 'Connection', 'connect', 'implementation']
109

10+
from .pq3 import implementation
1111
Connector = implementation.Connector
12-
Connection = implementation.Connection
13-
14-
_connectors = {}
15-
def connect(**kw):
16-
"""
17-
Create a PG-API connection using the given parameters.
18-
19-
See the `Connecting` section in the documentation for more information about
20-
suitable parameters.
21-
"""
22-
id = set(kw.items())
23-
c = _connectors.get(id)
24-
if c is None:
25-
c = Connector(**kw)
26-
_connectors[id] = c
27-
return c()
12+
Connection = implementation.Connector.Connection
13+
connect = implementation.connect
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,7 @@ def _negotiation(self):
17231723
sm = pq.element.Startup(**smd)
17241724
# encode the password in the hinted server_encoding as well
17251725
return pq.Negotiation(sm,
1726-
self.connector.password.encode(self.connector.server_encoding)
1726+
(self.connector.password or '').encode(self.connector.server_encoding)
17271727
)
17281728

17291729
def _connect(self, timeout = None):
@@ -2208,7 +2208,7 @@ def __init__(self, **kw):
22082208
self.port = int(kw.get('port'))
22092209
self.process = kw.get('process')
22102210
self.sslmode = kw.get('sslmode') or self.sslmode
2211-
self.database = kw.get('database')
2211+
self.database = kw.get('database') or None
22122212
self.sslkeyfile = kw.get('sslkeyfile')
22132213
self.sslcrtfile = kw.get('sslcrtfile')
22142214
self.sslrootcrtfile = kw.get('sslrootcrtfile')
@@ -2249,9 +2249,9 @@ def __init__(self, **kw):
22492249
self.ipv = 6
22502250

22512251
self.user = kw['user']
2252-
self.password = kw.get('password') or ''
2253-
self.options = kw.get('options')
2254-
self.settings = kw.get('settings') or {}
2252+
self.password = kw.get('password') or None
2253+
self.options = kw.get('options') or None
2254+
self.settings = kw.get('settings') or None
22552255

22562256
self.notifier = kw.get('notifier', self.notifier)
22572257

postgresql/driver/pythoncommand.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from .. import environ as pg_env
1717
from ..resolved import pythoncommand as pycmd
1818

19-
from .pgapi import Connector
19+
from . import Connector
2020

2121
pq_trace = optparse.make_option(
2222
'--pq-trace',

0 commit comments

Comments
 (0)