How to execute query saved in MS Access using pyodbc
There are a lot of tips online on how to use pyodbc to run a query in MS Access 2007, but all those queries are coded in the Python script itself. I would like to use pyodbc to call the queries already saved in MS Access. How can I do that? If the saved query in Access is a simple SELECT query with no parameters then the Access ODBC driver exposes it as a View so all you need to do is use the query name just like it was a table: import pyodbc connStr = ( r"Driver={Microsoft Access Driver (*.mdb, *.accdb)};" r"DBQ=C:\Users\Public\Database1.accdb;" ) cnxn = pyodbc.connect(connStr) sql = """\