That helped immensely... I was trying some different things trying to get at the results, but it never occurred to me to try iterating over it. The bit about some objects being iterable and some not is good to know!
Thanks, Monte On Fri, Dec 16, 2011 at 11:43 AM, Modulok <modu...@gmail.com> wrote: > >> How do I tell if it succeeded (short of trying an operation that should > be > >> blocked by foreign keys)? How do I use that cursor object returned by > the > >> pragma query to tell if its a '1' (on) or a '0' (off) and verify the > state? > > > The cursor object contains the result set. It's a python generator object. > (Or > at least a generator interface.) You have to iterate over it in order to > see > the resulting rows which are stored as a tuple. Not all operations return a > result row. (For example, conn.execute('pragma foreign_keys=ON' will > return a > cursor object, but it won't generate any result rows, as there were > none returned by the database.) > > To see the result of your second command, do something like this:: > > rows = conn.execute('pragma foreign_keys') > for r in rows: > print r > > > You'll then see something like this when foreign keys are turned on:: > > (1,) > > Or this when they're turned off:: > > (0,) > > Hope that helps. > -Modulok- > >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor