0

I wrote my Python app on a windows machine and now I am trying to deploy it to Heroku. At first, my commit kept failing because it couldn't install pyodbc. To fix that, I added a Heroku build pack to preinstall a required apt package first.

I included in the Aptfile:

unixodbc
unixodbc-dev
python-pyodbc
libsqliteodbc

I was able to successfully commit but now I am receiving the following error when trying to run the app:

pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'SQL Server' : file not found (0) (SQLDriverConnect)")

Here is the SQL connection syntax in my code that is working just fine on windows:

cnxn = pyodbc.connect(driver='{SQL Server}', host='Company.database.windows.net', database='MyDatabse',trusted_connection='no', user='###', password='###')

user2200270
  • 309
  • 1
  • 11
  • It looks like you are installing the ODBC Driver *Manager* (unixODBC) but not an actual ODBC *driver*. If you want to stick with items in the official OS repositories you could add `tdsodbc` to your list and then use `driver='/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so'` – Gord Thompson Jul 13 '20 at 14:44
  • I added `tdsodbc` to my aple file and now I''m getting this error: `[unixODBC][Driver Manager]Can't open lib '/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so' : file not found (0) (SQLDriverConnect)")` – user2200270 Jul 13 '20 at 16:59
  • That was the path to the .so file on my Ubuntu machine. Your path may be different. What Linux distribution is the Heroku machine based on? – Gord Thompson Jul 13 '20 at 17:37
  • Hmm, not really sure about any of that. I'm just using the free version of Heroku, totally new to deploying stuff, so I'm not sure how to figure out the answer to your question. – user2200270 Jul 13 '20 at 17:57
  • To clarify my previous comment, I'm on a windows machine, deploying to Heroku free version – user2200270 Jul 13 '20 at 18:15

0 Answers0