Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssl_client_cert passed is being assigned to proxies in Cursor object #300

Open
shek1608 opened this issue Feb 10, 2023 · 0 comments
Open

Comments

@shek1608
Copy link
Contributor

In function cursor of Class Connection, an object of class Cursor is created with ssl_client_cert and proxies as 7th and 8th parameters respectively as seen here:
https://github.com/druid-io/pydruid/blob/master/pydruid/db/api.py#L169-L177

The Cursor object's init has the 2 parameters exchanged, effectively putting ssl_client_cert's value into proxies and vice versa as seen here:
https://github.com/druid-io/pydruid/blob/master/pydruid/db/api.py#L199-L208

Example use case from python 3.8 using sqlalchemy:

from sqlalchemy import *
from sqlalchemy.engine import create_engine
engine = create_engine('druid+https://<user>@<host>:<port>/druid/v2/sql', connect_args = {'ssl_client_cert':('<path_to_cert>','<path_to_key>')})
conn = engine.connect();
res = conn.execute('SELECT "<column>" from <table> limit 10');

Having a print statement in the init function will show the value:

print("In cursor's init - ssl_client_cert= {} ; proxies= ".format(ssl_client_cert, proxies))

results in:

In cursor's init - ssl_client_cert= None ; proxies= ('<path_to_cert>','<path_to_key>')

The error thrown for my use case for the conn.execute line was:

  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 711, in merge_environment_settings
    no_proxy = proxies.get('no_proxy') if proxies is not None else None
AttributeError: 'tuple' object has no attribute 'get'

The above led me to debug the code and find this.

shek1608 added a commit to shek1608/pydruid that referenced this issue Feb 10, 2023
betodealmeida pushed a commit that referenced this issue Apr 29, 2024
* Correct order of parameters for Cursor's init

Fix for issue #300

* Update api.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant