I want to list all the tables of a sqlite3 database, but it doesn’t work. Let’s imagine that in ma database I have the following tables : foo1, foo2, foo3, … Then, with this code :
cur.execute("SELECT name FROM sqlite_master")
for table in cur:
print("The table is", table[0])
I have this output : The table is foo1
, whereas I’d like have this one :
The table is foo1
The table is foo2
The table is foo3
…
But if I modify the code to have :
cur.execute("SELECT name FROM sqlite_master")
print(cur.fetchone())
for table in cur:
print("The table is", table[0]
Then the output is :
(foo1,)
The table is foo2
So what’s wrong in my code ?