aboutsummaryrefslogtreecommitdiff
path: root/wqflask/base/species.py
diff options
context:
space:
mode:
authorMunyoki Kilyungi2022-09-02 17:28:26 +0300
committerBonfaceKilz2022-09-08 14:26:19 +0300
commit72336a5876ddffba15aede5e02546e7dbf7a19f5 (patch)
treeb2c675adab8ec76ca2c7b924820fa3b55450a48d /wqflask/base/species.py
parentf81265ac735b837d8241d366832d4b98c2080909 (diff)
downloadgenenetwork2-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/species.py')
-rw-r--r--wqflask/base/species.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/wqflask/base/species.py b/wqflask/base/species.py
index f303aabb..0a13315c 100644
--- a/wqflask/base/species.py
+++ b/wqflask/base/species.py
@@ -2,7 +2,7 @@ from collections import OrderedDict
from dataclasses import dataclass
from dataclasses import InitVar
from typing import Optional, Dict
-from flask import g
+from wqflask.database import database_connection
@dataclass
@@ -46,20 +46,20 @@ class Chromosomes:
"""Lazily fetch the chromosomes"""
chromosomes = OrderedDict()
if self.species is not None:
- query = (
+ cursor.execute(
"SELECT Chr_Length.Name, Chr_Length.OrderId, Length "
"FROM Chr_Length, Species WHERE "
"Chr_Length.SpeciesId = Species.SpeciesId AND "
- "Species.Name = "
- "'%s' ORDER BY OrderId" % self.species.capitalize())
+ "Species.Name = %s "
+ "ORDER BY OrderId", (self.species.capitalize(),))
else:
- query = (
+ cursor.execute(
"SELECT Chr_Length.Name, Chr_Length.OrderId, "
"Length FROM Chr_Length, InbredSet WHERE "
"Chr_Length.SpeciesId = InbredSet.SpeciesId AND "
"InbredSet.Name = "
- "'%s' ORDER BY OrderId" % self.dataset.group.name)
- results = g.db.execute(query).fetchall()
+ "%s ORDER BY OrderId", (self.dataset.group.name,))
+ results = cursor.fetchall()
for item in results:
chromosomes[item.OrderId] = IndChromosome(
item.Name, item.Length)