On Fri, Dec 16, 2011 at 1:43 PM, 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 >
If you're mucking about in the interactive prompt, and you just want to see the results quickly you can just turn it into a tuple or a list (list would be less typing): print(list(rows)) or just list(rows) HTH, Wayne
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor