WEB开发网
开发学院软件开发Python 把sqlalchemy的result当成struct使用 阅读

把sqlalchemy的result当成struct使用

 2008-11-10 13:21:28 来源:WEB开发网   
核心提示: >>> rst = db.query( "select * from adv_urlqueue where flg = '0'" )s_sql = [select * from adv_urlqueue where flg = '

>>> rst = db.query( "select * from adv_urlqueue where flg = '0'" )

s_sql = [select * from adv_urlqueue where flg = '0']

2008-04-18 13:29:17,030 INFO sqlalchemy.engine.base.Engine.0x..90 select * from adv_urlqueue where flg = '0'

2008-04-18 13:29:17,046 INFO sqlalchemy.engine.base.Engine.0x..90 None

>>> rst.rowcount

1L

###########################################

从这里可以看到已经取出数据.

查看下rst的一些属性和方法吧

>>> dir( rst )

['AmbiguousColumn', '_ResultProxy__echo', '_ResultProxy__key_cache', '_ResultProxy__keys', '_ResultProxy__props', '__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__', '__iter__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', '_convert_key', '_fetchall_impl', '_fetchmany_impl', '_fetchone_impl', '_get_col', '_has_key', '_init_metadata', '_process_row', 'close', 'closed', 'connection', 'context', 'cursor', 'dialect', 'fetchall', 'fetchmany', 'fetchone', 'keys', 'last_inserted_ids', 'last_inserted_params', 'last_updated_params', 'lastrow_has_defaults', 'rowcount', 'scalar', 'supports_sane_rowcount']

上一页  1 2 3 4 5  下一页

Tags:sqlalchemy result 当成

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接