Esempio n. 1
0
def loadAttendanceFromDB(dbpath):
	ret = list()
	match = re.search('(\w+?)(\d+)\.db$', dbpath)
	if match is None:
		return ret
	series = match.group(1)
	year = int(match.group(2))

	session = Session()
	session.bind = create_engine('sqlite:///%s' % dbpath)
	settings = Settings()
	settings.load(session)

	for row in session.execute("select d.firstname, d.lastname, count(distinct r.eventid) from runs as r, cars as c, drivers as d where r.carid=c.id and c.driverid=d.id and r.eventid < 100 group by d.id"):
		count = int(row[2])
		ret.append((series.lower(), year, row[0].lower().strip(), row[1].lower().strip(), count, int(count > settings.useevents)))

	return ret