install unixodbc in heroku requirements.txt
unixodbc unixodbc-dev python-pyodbc libsqliteodbc
Here is what the above code is Doing:
1. Importing the pyodbc module
2. Creating a connection to the database
3. Creating a cursor object
4. Executing a query
5. Fetching the results
6. Iterating over the results
7. Cleaning up