Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sql.h not found when installing PyODBC on Heroku

I'm trying to install PyODBC on Heroku, but I get fatal error: sql.h: No such file or directory in the logs when pip runs. How do I fix this error?

like image 839
shashi kanth Avatar asked Jul 11 '15 03:07

shashi kanth


People also ask

Is Pyodbc included in Python?

pyodbc is an open source Python module that makes accessing ODBC databases simple. It implements the DB API 2.0 specification but is packed with even more Pythonic convenience. Precompiled binary wheels are provided for most Python versions on Windows and macOS.

Does Pyodbc work on Linux?

pyodbc is a Python DB conformant module for ODBC databases. This tutorial shows how to use pyodbc with an ODBC driver, which you can download from this site. You can then connect Python on Linux and Unix to remote database such as Microsoft SQL Server, Oracle®, DB2, Microsoft Access, Sybase ASE and InterBase.


2 Answers

To follow up on the answer below...

Example for Ubuntu:

sudo apt-get install unixodbc unixodbc-dev 

Example for CentOS:

sudo yum install unixODBC-devel 

Example for Fedora:

sudo dnf install unixODBC-devel 

On Windows:

conn = pyodbc.connect('DRIVER={SQL Server};SERVER=yourserver.yourcompany.com;DATABASE=yourdb;UID=user;PWD=password') 

On Linux:

conn = pyodbc.connect('DRIVER={FreeTDS};SERVER=yourserver.yourcompany.com;PORT=1433;DATABASE=yourdb;UID=user;PWD=password;TDS_VERSION=7.2') 
like image 76
FlipperPA Avatar answered Sep 18 '22 08:09

FlipperPA


You can add Heroku build pack to preinstall required apt packages first

heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt 

Add Aptfile in the your directory root and to the repository as well

unixodbc unixodbc-dev python-pyodbc libsqliteodbc 

It will install everything you need to work with pyodbc or aioodbc packages from python on Heroku

like image 26
Most Wanted Avatar answered Sep 19 '22 08:09

Most Wanted