Conversation
kadler
left a comment
There was a problem hiding this comment.
A few REST/HTTP residual references and some notes
|
|
||
| class Db2Connection: | ||
| """ | ||
| Represents a REST HTTP connection that can be used to get the Python |
| @@ -0,0 +1,61 @@ | |||
| import requests | |||
| import json | |||
| @@ -0,0 +1,24 @@ | |||
| import unittest | |||
| import os | |||
| def __init__(self, database, username, password): | ||
|
|
||
| self.connection = dbi.connect(database=database, \ | ||
| user=username, password=password) |
There was a problem hiding this comment.
It's possible to just wrap ibm_db_dbi.connect:
def __init__(self, *args, **kwargs):
self.connection = dbi.connect(args, kwargs)https://www.digitalocean.com/community/tutorials/how-to-use-args-and-kwargs-in-python-3
This would allow users to pass any connection options they want, though is that something we actually want them to be able to do?
There was a problem hiding this comment.
Well, probably. Thoughts on having db, username, and password explicit (for comprehension), and adding **kwargs on the end?
There was a problem hiding this comment.
Yeah, you can have as many named parameters as you like followed by *args and **kwargs, however this would mess up positional argument handling unless you had the same named arguments and in the same order as ibm_db_dbi.connect. So I'd suggest only supporting kwargs.
Does that make sense?
| """ | ||
| if not response.ok: | ||
| raise TransportError("There was an error while executing the payload.") | ||
| """ |
|
|
||
| def __test_connection(self): | ||
| """ | ||
| Test that the DB2Sock REST transport exists and works properly |
| {'s': {'name': 'char', 'type': '128a', 'value': 'Hi there'}} | ||
| ] | ||
| }) | ||
| response = toolkit.execute() |
There was a problem hiding this comment.
No assertion? Looks like the test would never fail.
There was a problem hiding this comment.
We had a _test_connection funciton in the HTTP transport, because the HTTP transport didn
t actually "connect". Am removing the _test_connection function here.
|
Great enhancement! Key to the success of this project. We definitely want |
added db2 transport with ibm_db_dbi