@load "spawk"
BEGIN {
spawk_sesami["dbuser"] = "chat"
spawk_sesami["dbpassword"] = "xxx"
spawk_sesami["dbname"] = "chat"
}
{
spawk_submit("SELECT `login`, `name` FROM `user` WHERE `login` LIKE " spawk_escape($0))
while (spawk_fetchrow(user))
process_user(user)
}
function process_user(user, relation) {
print user[0]
spawk_submit("SELECT `related`, `relationship` FROM `relation` WHERE `user` = " spawk_escape(user[1]))
while (spawk_fetchrow(relation))
print "\t" relation[0]
}