From f8a3540c1ec70d36d046b309134d7808346a2bd7 Mon Sep 17 00:00:00 2001 From: naath Date: Sun, 6 Apr 2014 18:39:12 +0100 Subject: [PATCH] Added search by name --- cgiFiles/ancestors.py | 0 cgiFiles/countNames.py | 0 cgiFiles/everyPage.py | 0 cgiFiles/listPeople.py | 0 cgiFiles/listTerr.py | 0 cgiFiles/person.py | 0 cgiFiles/territory.py | 0 familyTree/askQuestion.py | 30 +++++++++++++++++++++++++++--- familyTree/printLists.py | 8 ++++---- 9 files changed, 31 insertions(+), 7 deletions(-) mode change 100644 => 100755 cgiFiles/ancestors.py mode change 100644 => 100755 cgiFiles/countNames.py mode change 100644 => 100755 cgiFiles/everyPage.py mode change 100644 => 100755 cgiFiles/listPeople.py mode change 100644 => 100755 cgiFiles/listTerr.py mode change 100644 => 100755 cgiFiles/person.py mode change 100644 => 100755 cgiFiles/territory.py diff --git a/cgiFiles/ancestors.py b/cgiFiles/ancestors.py old mode 100644 new mode 100755 diff --git a/cgiFiles/countNames.py b/cgiFiles/countNames.py old mode 100644 new mode 100755 diff --git a/cgiFiles/everyPage.py b/cgiFiles/everyPage.py old mode 100644 new mode 100755 diff --git a/cgiFiles/listPeople.py b/cgiFiles/listPeople.py old mode 100644 new mode 100755 diff --git a/cgiFiles/listTerr.py b/cgiFiles/listTerr.py old mode 100644 new mode 100755 diff --git a/cgiFiles/person.py b/cgiFiles/person.py old mode 100644 new mode 100755 diff --git a/cgiFiles/territory.py b/cgiFiles/territory.py old mode 100644 new mode 100755 diff --git a/familyTree/askQuestion.py b/familyTree/askQuestion.py index 179888c..364f088 100755 --- a/familyTree/askQuestion.py +++ b/familyTree/askQuestion.py @@ -77,7 +77,16 @@ def print_age_count(row,newLine): + link + newLine else: return print_row(row,newLine) - + + +def print_name_count(row,newLine): + if newLine=='
': + script = "name.py?name=" + row[0] + link = link_Template.substitute(script =\ + script, text = row[0]) + return str(row[1]) + " people called "+link + newLine + else: + return print_row(row,newLine) def print_tagged_name(relationship,row,newLine): if row[0]==None: @@ -227,8 +236,23 @@ def count_names(newLine): +" GROUP BY firstName"\ +" ORDER BY count(*) DESC;" - out = print_query(s,(),newLine) - + out = '' + for row in run_query(s,()): + out = out + print_name_count(row,newLine) + + return out + +def people_with_name(name,newLine): + s = "SELECT Name, ID"\ + +" FROM people"\ + +" WHERE Name LIKE ?;" + + out = '' + + t = (name + '%',) + + for row in run_query(s,t): + out = out + name_html(row,newLine) + newLine return out diff --git a/familyTree/printLists.py b/familyTree/printLists.py index f0810f0..0332d8e 100755 --- a/familyTree/printLists.py +++ b/familyTree/printLists.py @@ -7,9 +7,9 @@ import sys conn = askQuestion.connect() -#o = askQuestion.count_names('\n') +o = askQuestion.count_names('\n') -#print o +print o #o = askQuestion.count_birth_month('\n') #print o @@ -24,7 +24,7 @@ conn = askQuestion.connect() #o = askQuestion.list_people('\n') #print o -o = askQuestion.count_age_at_child('\n') -print o +#o = askQuestion.count_age_at_child('\n') +#print o askQuestion.close(conn) -- 2.30.2