如何在python3上显示在sqlite数据库中创建的所有表

时间:2015-07-03 14:11:59

标签: python sqlite

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)

the output is 
********************************
<sqlite3.Cursor object at 0x00272DE0>
Process finished with exit code 0
**************************************

但不是任何表..如何获取表名?

1 个答案:

答案 0 :(得分: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)
相关问题