aboutsummaryrefslogtreecommitdiff
path: root/gn3/db_utils.py
AgeCommit message (Collapse)Author
2022-11-02Fix pylint and mypy errorsMunyoki Kilyungi
* gn3/db/sample_data.py (get_trait_csv_sample_data): Pass __query directly to cursor.execute. Rename value to _value in for loop to make mypy pass. * gn3/db_utils.py (Connection): Add class docstring. (Connection.cursor): Add docstring. * mypy.ini: Add an entry for xapian.
2022-10-28Use Xapian index path from app settings.Arun Isaac
App settings should be accessed from current_app. It should not be hard-coded to a variable in a module. * gn3/db_utils.py: Do not import XAPIAN_DB_PATH from gn3.settings. (xapian_database): Accept path argument. * gn3/api/search.py: Import current_app from flask. (search_results): Pass Xapian index path to xapian_database.
2022-10-28Disable various pylint checks on Connection class.Arun Isaac
* gn3/db_utils.py (Connection): Disable missing-class-docstring, missing-function-docstring and too-few-public-methods pylint checks.
2022-10-26Add xapian database connection context manager.Arun Isaac
* gn3/settings.py (XAPIAN_DB_PATH): New variable. * gn3/db_utils.py: Import xapian and XAPIAN_DB_PATH from gn3.settings. (xapian_database): New function.
2022-10-18Add database connection context manager.Arun Isaac
* gn3/db_utils.py: Import contextlib. Import Any, Iterator, Protocol and Tuple from typing. (database_connector): Deprecate function. (Connection): New class. (database_connection): New function.
2022-08-22Use non-default MySQL port if presentFrederick Muriuki Muriithi
By default, MySQL/Mariadb connects at port 3306, however, the configuration variable `SQL_URI` could contain a different port. In that case, this commit allows the system to connect to the non-default port.
2022-03-11Fix some linting issuesFrederick Muriuki Muriithi
2022-03-08Create database connections within context managersFrederick Muriuki Muriithi
Use the `with` context manager to open database connections, so as to ensure that those connections are closed once the call is completed. This hopefully avoids the 'too many connections' error
2021-05-08gn3: db_utils: Remove mypy ignore stubBonfaceKilz
MySQLdb is already ignored in ".mypy.ini", added in 88c33df.
2021-05-08Fix pep-8 errorsBonfaceKilz
2021-04-12Integrate correlation APIAlexander Kabui
- add new api for gn2-gn3 sample r integration - delete map for sample list to values - add db util file - add python msql-client dependency - add db for fetching lit correlation results - add unittests for db utils - add tests for db_utils - modify api for fetching lit correlation results - refactor Mock Database Connector and unittests - add sql url parser - add SQL URI env variable - refactor code for db utils - modify return data for lit correlation - refactor tissue correlation endpoint - replace db_instance with conn