On Fri, May 18, 2012 at 5:34 AM, Dinesh B Vadhia
<dineshbvad...@hotmail.com> wrote:
> In the Python documentation
> (http://docs.python.org/library/sqlite3.html?highlight=sqlite#using-shortcut-methods)
> it says:
> "Using the nonstandard execute(), executemany() and executescript() methods
> of the Connection object, your code can be written more concisely because
> you don’t have to create the (often superfluous) Cursor objects explicitly.
> Instead, the Cursor objects are created implicitly and these shortcut
> methods return the cursor objects. This way, you can execute a SELECT
> statement and iterate over it directly using only a single call on the
> Connection object."
> Here is pseudo-code:
>
> db = sqlite.connect(path, ...)
> cursor = db.cursor()
>
> # normal method
> def doDBStuff():
>     cursor = db.cursor()
>     cursor.execute(somestatement) or cursor.executemany(somestatement) or
> cursor.executescript(somestatement)
>     cursor.close()
>     return
>
> # suggested method
> def doDbStuffCorrectly():
>     cursor.execute(somestatement) or cursor.executemany(somestatement) or
> cursor.executescript(somestatement)
>     return
>
I think you meant to use conn instead of cursor here?
> Does the implicit method close the cursor?  This would be important in a
> multi-user environment with read/write access.

The document says that these methods return a cursor

If you close the connection I would assume that the cursor would be
closed, since it is a method of the connection object.

But what does it actually mean to close the cursor?  In a muti-user
environment each user would have a different conn object and a
different cursor.
>
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
Joel Goldstick
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to