我正在查看https://alchimia.readthedocs.org/en/latest/的示例,但有一个问题:如何从其他函数返回结果,该函数使用与数据库的异步API?
会是这样的:
def FindNames():
result = yield engine.execute(users.select(users.c.name.startswith("D")))
return result
def processingResult():
result = FindNames()
d_users = yield result.fetchall()
for user in d_users:
print "Username: %s" % user[users.c.name]