sqlalchemy执行sql返回数据

conn=db.execute("select * from users")

conn.close(), resultProxy 用完之后, 需要close

conn.scalar(), 可以返回一个标量查询的值ResultProxy 类是对Cursor类的封装(在文件sqlalchemy\engine\base.py),ResultProxy 类有个属性cursor即对应着原来的

conn.ResultProxy 类有很多方法对应着Cursor类的方法, 另外有扩展了一些属性/方法.resultProxy.fetchall()

conn.fetchmany()

conn.fetchone()

conn.first()

conn.scalar()

conn.returns_rows #True if this ResultProxy returns rows.resultProxy.rowcount #return rows affected by an UPDATE or DELETE statement. It is not intended to provide the number of rows present from a SELECT.


猜你喜欢

转载自blog.csdn.net/qq_39140630/article/details/80966624