Skip to content

Commit 059ebfe

Browse files
committed
Fix Python 2 bug in DatabaseTransport
Also fix bug generating self.procedure if schema is falsey.
1 parent cab6ac8 commit 059ebfe

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/itoolkit/transport/database.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ class DatabaseTransport(XmlServiceTransport):
1515
to use
1616
**kwargs: Base transport options. See `XmlServiceTransport`.
1717
"""
18-
def __init__(self, conn, *args, schema='QXMLSERV', **kwargs):
19-
# TODO: When we drop Python 2 support, change *args to * and
20-
# remove this block of code. *args is used to make schema
21-
# a keyword-only argument
22-
if len(args):
23-
raise TypeError(
24-
"__init__() takes 1 positional argument, but {} were given"
25-
.format(len(args)+1)
26-
)
18+
def __init__(self, conn, **kwargs):
19+
# TODO: When we drop Python 2 support, add `*, schema='QXMLSERV'`
20+
# to the function variables, to make schema a keyword-only argument
21+
# and remove this block of code
22+
if 'schema' in kwargs:
23+
schema = kwargs['schema']
24+
del kwargs['schema']
25+
else:
26+
schema = 'QXMLSERV'
2727

2828
if not hasattr(conn, 'cursor'):
2929
raise ValueError(
@@ -36,9 +36,9 @@ def __init__(self, conn, *args, schema='QXMLSERV', **kwargs):
3636

3737
self.conn = conn
3838

39+
self.procedure = "iPLUGR512K"
3940
if schema:
40-
self.procedure = schema + "."
41-
self.procedure += "iPLUGR512K"
41+
self.procedure = schema + "." + self.procedure
4242

4343
# We could simplify to just using execute, since we don't care
4444
# about output parameters, but ibm_db throws weird errors when

0 commit comments

Comments
 (0)