diff options
Diffstat (limited to 'wqflask/base/species.py')
-rw-r--r-- | wqflask/base/species.py | 14 |
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) |