Python gets the column name of the SQLite query result table
- 2020-06-07 04:40:57
This article illustrates how Python gets the column names of the SQLite query results table. To share for your reference, specific as follows:
Get the column name of the query result table:
db = sqlite.connect('data.db') cur = db.cursor() cur.execute("select * from table") col_name_list = [tuple for tuple in cur.description] print col_name_list
Get all column names:
cur.execute("PRAGMA table_info(table)") print cur.fetchall()
More about Python related content interested readers to view this site project: "common database operations Python skills summary", "Python data structure and algorithm tutorial", "Python function using techniques", "Python string skills summary", "Python introduction and advanced tutorial" and "Python file and directory skills summary"
I hope this article has been helpful in Python programming.