0

我想使用 sqlalchemy 从 mysql 数据库中获取数据并使用不同类中的数据。基本上我一次获取一行,使用数据,获取另一行,使用数据等等。我遇到了这样做有些问题..

基本上,我如何从 mysql 数据中一次输出一行数据?.. 我查看了所有教程,但它们并没有太大帮助。

4

2 回答 2

1

你到底遇到了什么问题?

您可以简单地遍历 ResultProxy 对象:

对于 conn_or_sess_or_engine.execute(selectable_obj_or_SQLstring) 中的行:
   do_something_with(行)
于 2009-02-11T10:36:33.547 回答
0

From what I understand, you're interested in something like this:

# s is object returned by the .select() method
rs = s.execute()
row = rs.fetchone()
# do something with the row
row = rs.fetchone()
# do something with another row

You can find this in a tutorial here.

于 2009-02-11T09:59:46.550 回答