AlexW AlexW - 1 month ago 5x
Python Question

Not selecting data from table

I want to use Python to manually update a SQLite database created in django.

I found the name of the DB and am testing using a

but I am getting an error that I do not understand.

>>> import sqlite3
>>> conn = sqlite3.connect('db.sqlite3')
>>> c = conn.cursor()
>>> c.execute("SELECT * from oncall_pduser")
<sqlite3.Cursor object at 0x7fcb92697650>
>>> conn.execute("SELECT * from oncall_pduser")
<sqlite3.Cursor object at 0x7fcb92697880>


What does this error mean?

These are the parms and I am running Python logged in as root

-rw-r--r-- 1 apache root 38912 May 9 16:47 db.sqlite3


<sqlite3.Cursor object at 0x7fcb92697650> is not an error - it is a Cursor object string representation. To see the actual results of the query, use fetchall() method:

c.execute("SELECT * from oncall_pduser")
for row in c.fetchall():

Or, to be more memory efficient, you can just iterate over the cursor:

for row in c: