import sqlite3
conn = sqlite3.connect('boo2.db')
c = conn.cursor()
x = c.execute("SELECT * FROM sqlite_master where type='table'")
for y in x:
print(x)
输出是
********************************
<sqlite3.Cursor object at 0x00272DE0>
Process finished with exit code 0
**************************************
但不是任何表...如何获取表名称?
您需要从查询中获取结果:
import sqlite3
conn = sqlite3.connect('boo2.db')
c = conn.cursor()
x=c.execute("SELECT * FROM sqlite_master where type='table'")
for y in x.fetchall():
print(y)