From: naath Date: Sun, 6 Apr 2014 11:16:18 +0000 (+0100) Subject: sort children by birth order, add info about age of parent at birth X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~naath/git?a=commitdiff_plain;h=dcdd1250ae9657b24ebfe917da2124ec6ef5530e;p=familyTree.git sort children by birth order, add info about age of parent at birth --- diff --git a/familyTree/askQuestion.py b/familyTree/askQuestion.py index d2f5e21..dfa1fc7 100755 --- a/familyTree/askQuestion.py +++ b/familyTree/askQuestion.py @@ -503,6 +503,7 @@ def person_info(personID,newLine): output = output + 'ID: '+str(row[0]) +newLine output = output + print_tagged_name('Name',[row[1], row[0]],newLine) +newLine output = output + 'Born: '+row[3] + newLine + bornYear = row[4] output = output + 'Died: '+row[5] + newLine s = "SELECT * FROM styles WHERE ID = ?" @@ -563,10 +564,11 @@ def person_info(personID,newLine): output = output + newLine #find children - s = "Select people.NAME, people.ID from"\ - +" people INNER JOIN parents"\ + s = "Select people.NAME, people.ID ,people.bornYear"\ + +" FROM people INNER JOIN parents"\ +" ON people.ID = parents.ID"\ - +" WHERE parents.parentID = ?" + +" WHERE parents.parentID = ?"\ + +" ORDER BY people.bornYear;" for row in run_query(s,t): output = output + print_tagged_name('Child',row,newLine) @@ -579,8 +581,12 @@ def person_info(personID,newLine): ids = (row[1],t[0]) - for row in run_query(u,ids): - output = output + print_tagged_name('With',row,newLine) + for r in run_query(u,ids): + output = output + print_tagged_name('With',r,newLine) + + #age when child born + age = row[2]-bornYear + output = output[:-4] + " at the age of "+str(age) + newLine output = output + newLine