0
如何僅提取數據庫中表的列名?優化sql輸出
import sqlite3
conn = sqlite3.connect('example3.db')
c = conn.cursor()
c.execute('SELECT name FROM sqlite_master WHERE type=\'table\'') #list all tables therein
print c.fetchall()
c.execute('SELECT sql FROM sqlite_master WHERE type=\'table\' AND name=\'students\'') #list columns in table 'students'
print c.fetchall()
conn.close()