def inbreedingByYear(pedobj):
curs = pyp_db.getCursor(pedobj.kw['database_name'])
# Check and see if the pedigree has already been loaded. If not, do it.
if not pyp_db.tableExists(pedobj.kw['database_name'], pedobj.kw['dbtable_name']):
pyp_db.loadPedigreeTable(pedobj)
MYQUERY = "SELECT birthyear, pyp_mean(coi) FROM %s GROUP BY birthyear \
ORDER BY birthyear ASC" % (pedobj.kw['dbtable_name'])
curs.execute(MYQUERY)
myresult = curs.fetchall()
result_dict = {}
for _mr in myresult:
_level, _mean = _mr
result_dict[_level] = _mean
return result_dict
You should always check to see if your pedigree has been loaded into the database before you try and make queries against the pedigree table or your program may crash.