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

connection class as parameter in database class #14

Merged
merged 2 commits into from
Mar 12, 2020

Conversation

phainom
Copy link
Collaborator

@phainom phainom commented Mar 3, 2020

This pull request is to refactor the Database class to initialize with a custom Connection class instead of calling it statically. This is the result of the discussion in #11, but does not cope with the issue there, but rather sets the ground work for having more extensibility with custom Connection classes.

I also showed how to extend the current setup in examples/connection_subclass.py. The idea is to mostly leave the Database class as is, but be able to extend / change the backend to accomodate custom needs.

Please review if this change goes along what you had in mind, @wahani! Also please pull and test, since I also refactored the Pipfile heavily. No tests were added, since no new features were added.

@phainom phainom added the enhancement New feature or request label Mar 3, 2020
@phainom phainom requested a review from wahani March 3, 2020 21:23
@phainom phainom self-assigned this Mar 3, 2020
Copy link
Member

@wahani wahani left a comment

Choose a reason for hiding this comment

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

Looks good to me! I guess it does what we talked about. See my one comment below.

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

wahani commented Mar 4, 2020

Tests pass on Travis and locally on my machine. However we get the following warnings:

=============================== warnings summary ===============================

.venv/lib/python3.6/distutils/__init__.py:4

  /home/travis/build/INWTlab/dbrequests/.venv/lib/python3.6/distutils/__init__.py:4: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses

    import imp

dbrequests/tests/test_connection.py::TestConnection::test_send_data_update

dbrequests/tests/test_database.py::TestDatabase::test_send_data_update

  /home/travis/build/INWTlab/dbrequests/.venv/lib/python3.6/site-packages/pymysql/cursors.py:170: Warning: (1364, "Field 'name' doesn't have a default value")

    result = self._query(query)

dbrequests/tests/test_connection.py::TestConnection::test_send_data_update

dbrequests/tests/test_database.py::TestDatabase::test_send_data_update

  /home/travis/build/INWTlab/dbrequests/.venv/lib/python3.6/site-packages/pymysql/cursors.py:170: Warning: (1364, "Field 'owner' doesn't have a default value")

    result = self._query(query)

-- Docs: https://docs.pytest.org/en/latest/warnings.html

================== 25 passed, 5 warnings in 212.62s (0:03:32) ==================

I guess the warning about default values can be ignored, is there a way to accept, suppress these warnings? Then there is something about imp vs. importlib, which I can't make sense of. It seems these are not even part of the package?

@phainom
Copy link
Collaborator Author

phainom commented Mar 4, 2020 via email

@phainom phainom merged commit 80384b6 into master Mar 12, 2020
@phainom
Copy link
Collaborator Author

phainom commented Mar 12, 2020

The new version has been deployed to pypi.org. Please @wahani if you still use your own pypi server internally do the same (I dont recall if I had CD implemented, please check). I implemented setup.py publish for this.

btw, we should build something similar for deploying to pypi and thinking about CD to pypi.

@phainom phainom deleted the feature/#11-connection-refactor branch March 28, 2020 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Syntax for 'replace' is MySQL/MariaDB specific and not working with Postgres-based databases
2 participants