I have a database called "default.db" and it is a working database [I can access it through the SQLite utilities and see the tables inside].
I have this code for accessing the database:
from pysqlite2 import dbapi2 as sqlite
conn = sqlite.connect("default.db")
cur = conn.cursor()
#retrieve all database data
cur.execute("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;")
print "fetch all"
cur.fetchall()
print "printing"
print cur
print conn
for i in cur:
print "item"
print i
The output is:
fetch all
printing
<pysqlite2.dbapi2.Cursor object at 0xb74a2de0>
<pysqlite2.dbapi2.Connection object at 0xb74713d8>
done
But if I run the commands individually I get this result from the code:
>>> cur.fetchall()
[(u'cards',), (u'data_for_fact',), (u'fact_views',), (u'fact_views_for_card_type',), (u'facts',), (u'global_variables',), (u'log',), (u'sqlite_sequence',), (u'tags',), (u'tags_for_card',)]
My question is: How can I fix this, and what is going wrong? I'm not getting any errors connecting to the db [its not reporting any].
edit: I tried saving the fetchall to an variable, but the variable prints out as []. (Empty)