Python论坛  - 讨论区

标题:Re: [python-chinese]今天试了一下pysqlite

2006年04月25日 星期二 13:09

nsinit nsinit at 163.com
Tue Apr 25 13:09:47 HKT 2006

imcs ee£º


>ÏÖÔÚµÚÒ»¸ö·½·¨ºÃÏñ·µ»ØµÄÊÇintÀàÐÍÁË£¬µÚ¶þ¸ö·½·¨·µ»Ø£­1ÁË¡£

ÎҵĻ·¾³£º
pysqlite-2.2.2.win32-py2.4.exe

²âÊÔ½á¹û£º
>>> cur.execute('select * from test');

>>> print cur.fetchall()
[(1, u'name1')]
>>> cur.execute('select * from test');

>>> cur.rowcount
-1
>>> cur.execute('delete from test');

>>> cur.rowcount
0

ÎĵµËµÃ÷£º
¡¶pysqlite usage guide¡·

rowcount attribute

Although pysqlite's Cursors implement this attribute, the database engine's own support for the determination of "rows affected"/"rows selected" is quirky.

For SELECT statements, rowcount is always None because pysqlite cannot determine the number of rows a query produced until all rows were fetched.

For DELETE statements, SQLite reports rowcount as 0 if you make a DELETE FROM table without any condition.

For executemany statements, pysqlite sums up the number of modifications into rowcount.

As required by the Python DB API Spec, the rowcount attribute "is -1 in case no executeXX() has been performed on the cursor or the rowcount of the last operation is not determinable by the interface".




= = = = = = = = = = = = = = = = = = = =

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡	nsinit
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡	2006-04-25



[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号