From 36c85b7f82c584b869182f097cd0b8577dfef0d4 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Wed, 29 Jul 2020 22:12:53 +0300 Subject: Reformat sql queries to be one line * wqflask/wqflask/api/gen_menu.py (get_species, get_groups, phenotypes_exist) (genotypes_exist)[sql]: Strip white spaces and newlines from query and make the sql query one line. --- wqflask/wqflask/api/gen_menu.py | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/wqflask/wqflask/api/gen_menu.py b/wqflask/wqflask/api/gen_menu.py index cfce0c8e..69a927cd 100644 --- a/wqflask/wqflask/api/gen_menu.py +++ b/wqflask/wqflask/api/gen_menu.py @@ -31,9 +31,7 @@ def gen_dropdown_json(): def get_species(): """Build species list""" - results = g.db.execute("""SELECT Name, MenuName - FROM Species - ORDER BY OrderId""").fetchall() + results = g.db.execute("SELECT Name, MenuName FROM Species ORDER BY OrderId").fetchall() species = [] for result in results: @@ -47,12 +45,12 @@ def get_groups(species): for species_name, _species_full_name in species: groups[species_name] = [] - results = g.db.execute("""SELECT InbredSet.Name, InbredSet.FullName, IFNULL(InbredSet.Family, 'None') - FROM InbredSet, Species - WHERE Species.Name = '{}' AND - InbredSet.SpeciesId = Species.Id - GROUP by InbredSet.Name - ORDER BY IFNULL(InbredSet.FamilyOrder, InbredSet.FullName) ASC, IFNULL(InbredSet.Family, InbredSet.FullName) ASC, InbredSet.FullName ASC, InbredSet.MenuOrderId ASC""".format(species_name)).fetchall() + results = g.db.execute( + ("SELECT InbredSet.Name, InbredSet.FullName, IFNULL(InbredSet.Family, 'None') " + + "FROM InbredSet, Species WHERE Species.Name = '{}' AND InbredSet.SpeciesId = " + + "Species.Id GROUP by InbredSet.Name ORDER BY IFNULL(InbredSet.FamilyOrder, " + + "InbredSet.FullName) ASC, IFNULL(InbredSet.Family, InbredSet.FullName) ASC, " + + "InbredSet.FullName ASC, InbredSet.MenuOrderId ASC").format(species_name)).fetchall() for result in results: family_name = "Family:" + str(result[2]) @@ -92,9 +90,9 @@ def get_types(groups): return types def phenotypes_exist(group_name): - results = g.db.execute("""SELECT Name - FROM PublishFreeze - WHERE PublishFreeze.Name = '{}'""".format(group_name+"Publish")).fetchone() + results = g.db.execute( + ("SELECT Name FROM PublishFreeze " + + "WHERE PublishFreeze.Name = '{}'").format(group_name+"Publish")).fetchone() if results != None: return True @@ -102,9 +100,9 @@ def phenotypes_exist(group_name): return False def genotypes_exist(group_name): - results = g.db.execute("""SELECT Name - FROM GenoFreeze - WHERE GenoFreeze.Name = '{}'""".format(group_name+"Geno")).fetchone() + results = g.db.execute( + ("SELECT Name FROM GenoFreeze " + + "WHERE GenoFreeze.Name = '{}'").format(group_name+"Geno")).fetchone() if results != None: return True -- cgit v1.2.3