summaryrefslogtreecommitdiff
path: root/lib/extras.py
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2016-08-15 02:51:10 +0100
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2016-08-15 02:51:10 +0100
commitb006190312684679bf03f8b324bade6861f19436 (patch)
tree8cbb914d5a47a7eb5a0df407a70bec916f6f3274 /lib/extras.py
parent1d950748af199d76069a5fb71bd9f7ace7a2e50e (diff)
parent47a312cf836e0c4dc2d198f72a139e9af758f443 (diff)
downloadpsycopg2-b006190312684679bf03f8b324bade6861f19436.tar.gz
Merge branch 'drop-py25'
Diffstat (limited to 'lib/extras.py')
-rw-r--r--lib/extras.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/extras.py b/lib/extras.py
index 6ae9851..7a3a925 100644
--- a/lib/extras.py
+++ b/lib/extras.py
@@ -40,7 +40,6 @@ from psycopg2 import extensions as _ext
from psycopg2.extensions import cursor as _cursor
from psycopg2.extensions import connection as _connection
from psycopg2.extensions import adapt as _A, quote_ident
-from psycopg2.extensions import b
from psycopg2._psycopg import REPLICATION_PHYSICAL, REPLICATION_LOGICAL
from psycopg2._psycopg import ReplicationConnection as _replicationConnection
from psycopg2._psycopg import ReplicationCursor as _replicationCursor
@@ -575,7 +574,7 @@ class UUID_adapter(object):
return self
def getquoted(self):
- return b("'%s'::uuid" % self._uuid)
+ return ("'%s'::uuid" % self._uuid).encode('utf8')
def __str__(self):
return "'%s'::uuid" % self._uuid
@@ -635,7 +634,7 @@ class Inet(object):
obj = _A(self.addr)
if hasattr(obj, 'prepare'):
obj.prepare(self._conn)
- return obj.getquoted() + b("::inet")
+ return obj.getquoted() + b"::inet"
def __conform__(self, proto):
if proto is _ext.ISQLQuote:
@@ -742,7 +741,7 @@ class HstoreAdapter(object):
def _getquoted_8(self):
"""Use the operators available in PG pre-9.0."""
if not self.wrapped:
- return b("''::hstore")
+ return b"''::hstore"
adapt = _ext.adapt
rv = []
@@ -756,23 +755,23 @@ class HstoreAdapter(object):
v.prepare(self.conn)
v = v.getquoted()
else:
- v = b('NULL')
+ v = b'NULL'
# XXX this b'ing is painfully inefficient!
- rv.append(b("(") + k + b(" => ") + v + b(")"))
+ rv.append(b"(" + k + b" => " + v + b")")
- return b("(") + b('||').join(rv) + b(")")
+ return b"(" + b'||'.join(rv) + b")"
def _getquoted_9(self):
"""Use the hstore(text[], text[]) function."""
if not self.wrapped:
- return b("''::hstore")
+ return b"''::hstore"
k = _ext.adapt(self.wrapped.keys())
k.prepare(self.conn)
v = _ext.adapt(self.wrapped.values())
v.prepare(self.conn)
- return b("hstore(") + k.getquoted() + b(", ") + v.getquoted() + b(")")
+ return b"hstore(" + k.getquoted() + b", " + v.getquoted() + b")"
getquoted = _getquoted_9