diff options
author | Munyoki Kilyungi | 2022-09-02 17:28:26 +0300 |
---|---|---|
committer | BonfaceKilz | 2022-09-08 14:26:19 +0300 |
commit | 72336a5876ddffba15aede5e02546e7dbf7a19f5 (patch) | |
tree | b2c675adab8ec76ca2c7b924820fa3b55450a48d /wqflask/base/mrna_assay_tissue_data.py | |
parent | f81265ac735b837d8241d366832d4b98c2080909 (diff) | |
download | genenetwork2-72336a5876ddffba15aede5e02546e7dbf7a19f5.tar.gz |
Replace g.db with database_connection() context manager
* wqflask/base/mrna_assay_tissue_data.py: Replace "flask.g" with database_connection.
(MrnaAssayTissueData.__init__): Use database_connection.
(MrnaAssayTissueData.get_symbol_values_pairs): Ditto.
* wqflask/base/species.py: Replace "Flask.g" imports with
"database_connection".
(Chromosomes.chromosomes): Use database_connection.
* wqflask/base/trait.py: Import database_connection.
(retrieve_trait_info): Use database_connection.
* wqflask/utility/authentication_tools.py: Replace "flask.g" with
database_connection.
(get_group_code): Use database_connection.
* wqflask/utility/helper_functions.py: Replace "flask.g" with
"database_connection".
(get_species_groups): Use database_connection.
* wqflask/wqflask/db_info.py: Replace "Flask" and "g" with
"database_connection".
(InfoPage.get_info): Use database_connection.
* wqflask/wqflask/do_search.py (DoSearch.execute): Use
database_connection().
* wqflask/wqflask/external_tools/send_to_geneweaver.py: Replace
"Flask" and "g" import with database_connection.
(test_chip): Use database_connection.
* wqflask/wqflask/external_tools/send_to_webgestalt.py: Replace
"Flask, g" imports with database_connection.
(test_chip): Use database_connection.
* wqflask/wqflask/gsearch.py: Replace "Flask" and "g" import with
database_connection.
(GSearch.__init__): Use database_connection.
* wqflask/wqflask/interval_analyst/GeneUtil.py (loadGenes):
Use database_connection().
* wqflask/wqflask/show_trait/SampleList.py: Replace "flask.g import"
with database_connection.
(SampleList.get_attributes): Use database_connection.
(SampleList.get_extra_attribute_values): Ditto.
* wqflask/wqflask/show_trait/show_trait.py: Replace "Flask" and "g"
import with database_connection.
(ShowTrait.__init__): Use database_connection.
(ShowTrait.get_external_links): Ditto.
(get_nearest_marker): Ditto.
Diffstat (limited to 'wqflask/base/mrna_assay_tissue_data.py')
-rw-r--r-- | wqflask/base/mrna_assay_tissue_data.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/wqflask/base/mrna_assay_tissue_data.py b/wqflask/base/mrna_assay_tissue_data.py index d7e747aa..b371e39f 100644 --- a/wqflask/base/mrna_assay_tissue_data.py +++ b/wqflask/base/mrna_assay_tissue_data.py @@ -1,6 +1,6 @@ import collections -from flask import g +from wqflask.database import database_connection from utility import db_tools from utility import Bunch @@ -49,7 +49,11 @@ class MrnaAssayTissueData: # lower_symbols[gene_symbol.lower()] = True if gene_symbol != None: lower_symbols[gene_symbol.lower()] = True - results = list(g.db.execute(query).fetchall()) + + results = None + with database_connection() as conn, conn.cursor() as cursor: + cursor.execute(query) + results = cursor.fetchall() for result in results: symbol = result[0] if symbol is not None and lower_symbols.get(symbol.lower()): @@ -81,9 +85,10 @@ class MrnaAssayTissueData: FROM TissueProbeSetXRef, TissueProbeSetData WHERE TissueProbeSetData.Id IN {} and TissueProbeSetXRef.DataId = TissueProbeSetData.Id""".format(db_tools.create_in_clause(id_list)) - - - results = g.db.execute(query).fetchall() + results = [] + with database_connection() as conn, conn.cursor() as cursor: + cursor.execute(query) + results = cursor.fetchall() for result in results: if result.Symbol.lower() not in symbol_values_dict: symbol_values_dict[result.Symbol.lower()] = [result.value] |