I have a table in ms-access db, and I need to fetch just the column names of that table, into a list or a tuple.
If someone can suggest a query or point me to documentation on this.
Similar to the question here, you could do something like this:
# -*- coding: utf-8 -*-
import pypyodbc
cnxn = pypyodbc.connect(
r'Driver={Microsoft Access Driver (*.mdb, *.accdb)};' +
r'DBQ=C:\Users\Public\Database1.accdb')
crsr = cnxn.cursor()
res = crsr.execute("SELECT * FROM Clients WHERE 1=0")
columnList = [tuple[0] for tuple in res.description]
crsr.close()
cnxn.close()
print(columnList)