本文實例講述了Python獲取SQLite查詢結果表列名的方法。分享給大家供大家參考,具體如下:
獲得查詢結果表的列名:
db = sqlite.connect('data.db')cur = db.cursor()cur.execute("select * from table")col_name_list = [tuple[0] for tuple in cur.description]print col_name_list獲得所有列名:
cur.execute("PRAGMA table_info(table)")print cur.fetchall()希望本文所述對大家Python程序設計有所幫助。
新聞熱點
疑難解答