当使用 SQLAlchemy 从数据库中检索行时,您可以使用
query = "SELECT some_col FROM some_table"
row = session.execute(query).fetchone()
Run Code Online (Sandbox Code Playgroud)
但是,您也可以这样做:
query = "SELECT some_col FROM some_table LIMIT 1"
row = session.execute(query).fetchall()
Run Code Online (Sandbox Code Playgroud)
是否有任何理由选择其中一种而不是另一种,例如更好的性能?
sqlalchemy ×1