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

resolves #27 port field in creds object #34

Merged
merged 13 commits into from
May 10, 2020

Conversation

wahani
Copy link
Member

@wahani wahani commented May 1, 2020

Notes

  • I had to refactor the sub-class (mysql) quite a bit, so that I can take advantage of this new logic. I think this makes it a bit less complicated.
  • I noticed that we can remove the connection_class argument from the Database class, and instead do something like:
class Database:
    connection_class = DefaultConnection
    def __init__(self, ...):
        ...

This still allows us to override the Connection class in any derived sub-class and brings two advantages:

  • (a): we can remove it from the public interface. The Database class is for the user and the argument does not make sense. A user is not supposed to even now about the Connection class; that's an implementation detail.
  • (b): when we derive the subclass, we do not have to override the complete init method, and also do not need to keep track of upstream changes. Currently a new argument to init forces us to modify all derived sub-classes which override init. Yes, currently only one, but I have made several errors due to the suptle change in the call to the super init method already. My impression is, that defining that global constant may be more transparent.

@wahani wahani requested review from phainom and Cattes May 2, 2020 10:47
@wahani wahani self-assigned this May 2, 2020
@wahani wahani added bug Something isn't working enhancement New feature or request labels May 2, 2020
@wahani wahani linked an issue May 2, 2020 that may be closed by this pull request
@wahani
Copy link
Member Author

wahani commented May 2, 2020

@Cattes I added you as a reviewer to get some feedback if the handling of SSL certificates would work for you in this version. Also see my comment here: #12 (comment)

@wahani wahani marked this pull request as ready for review May 2, 2020 10:50
Copy link

@Cattes Cattes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not so familiar with dict.pop and argument passing but it looks ok as far as I can see.
Do I understand the new test fixture correctly, that you define a dict with an addtional argument local_infile = 0 which is passed on to the underlying db driver? And this results in a test failure when you try to send data not coming from a file? Is local_infile an argument of the pymysql driver?

@wahani
Copy link
Member Author

wahani commented May 6, 2020

With this test, I only check that additional fields in the credentials are properly handed over as connection_args to sqlalchemy.create_engine. local_infile is set to 1 by default for dbrequests.mysql, and I simply check, that I can override it. Instead of your proposition in #12, you may now simply add ssl to the creds object, and it should be used. Along with all additional parameters optionally passed down with connect_args.

Copy link
Collaborator

@phainom phainom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

dbrequests/database.py Outdated Show resolved Hide resolved
dbrequests/database.py Outdated Show resolved Hide resolved
@wahani
Copy link
Member Author

wahani commented May 6, 2020

@phainom from #34 (comment) do you have an opinion about:

I noticed that we can remove the connection_class argument from the Database class, and instead do something like:

@phainom
Copy link
Collaborator

phainom commented May 6, 2020

@phainom from #34 (comment) do you have an opinion about:

I noticed that we can remove the connection_class argument from the Database class, and instead do something like:

Sorry, overlooked it. In the subclass you would override the constant with a global keyword?

I agree the current implementation complicates things, if there is a better solution and there is no namespace confusion I am all for it.

@wahani
Copy link
Member Author

wahani commented May 6, 2020

In the subclass you would override the constant with a global keyword?

Yes, in the sub-class you can simply override the constant with some import. I will test if it works and solve it directly together with the other issues in this PR.

@wahani wahani merged commit 1a31358 into master May 10, 2020
@wahani wahani deleted the bugfix27/port-field-in-creds-object branch May 10, 2020 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: specify the port in a creds object Passing SSL certificates to mysql and postgresql
3 participants