diff options
author | Frederick Muriuki Muriithi | 2022-09-06 11:56:02 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-09-06 11:56:02 +0300 |
commit | a5b999a249cf5434e4a2a7fe21cf9b26357bc69f (patch) | |
tree | 3af7393fef527cbc831835863d816df09e230587 /wqflask | |
parent | 2cd740180850c959ae54efb72b14255c358e181c (diff) | |
download | genenetwork2-a5b999a249cf5434e4a2a7fe21cf9b26357bc69f.tar.gz |
Set up the self.* variables from query results
Set up the appropriate self.* variables from the results of running
the appropriate query.
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/base/data_set.py | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index da3c0628..f66bf186 100644 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -628,23 +628,30 @@ class DataSet: try: query = "" _vars = None + query_args = (self.name, self.name, self.name) if self.type == "ProbeSet": - query = """ -SELECT ProbeSetFreeze.Id, ProbeSetFreeze.Name, ProbeSetFreeze.FullName, ProbeSetFreeze.ShortName, ProbeSetFreeze.DataScale, Tissue.Name -FROM ProbeSetFreeze, ProbeFreeze, Tissue -WHERE ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id -AND ProbeFreeze.TissueId = Tissue.Id -AND (ProbeSetFreeze.Name = %s OR ProbeSetFreeze.FullName = %s OR ProbeSetFreeze.ShortName = %s""" - _vars = (self.id, self.name, self.fullname, self.shortname, self.data_scale, self.tissue,) + query = ( + "SELECT ProbeSetFreeze.Id, ProbeSetFreeze.Name, " + "ProbeSetFreeze.FullName, ProbeSetFreeze.ShortName, " + "ProbeSetFreeze.DataScale, Tissue.Name " + "FROM ProbeSetFreeze, ProbeFreeze, Tissue " + "WHERE ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id " + "AND ProbeFreeze.TissueId = Tissue.Id " + "AND (ProbeSetFreeze.Name = %s OR ProbeSetFreeze.FullName = %s OR ProbeSetFreeze.ShortName = %s)") else: - query = """ -SELECT Id, Name, FullName, ShortName FROM %s -WHERE (Name = %s OR FullName = '%s' OR ShortName = %s)""" + query = ( + "SELECT Id, Name, FullName, ShortName " + f"FROM {self.type}Freeze " + "WHERE (Name = %s OR FullName = %s OR ShortName = %s)") self.tissue = "N/A" - _vars = (self.id, self.name, self.fullname, self.shortname,) with database_connection() as conn, conn.cursor() as cursor: - cursor.execute(query, (query_args,)) + cursor.execute(query, query_args) _vars = cursor.fetchone() + if self.type == "ProbeSet": + (self.id, self.name, self.fullname, self.shortname, + self.data_scale, self.tissue) = _vars + else: + self.id, self.name, self.fullname, self.shortname = _vars except TypeError: pass |