Can’t open lib ‘ODBC Driver 13 for SQL Server’? Sym linking issue?

Running: odbcinst -j It yielded: unixODBC 2.3.4 DRIVERS…………: /etc/odbcinst.ini SYSTEM DATA SOURCES: /etc/odbc.ini FILE DATA SOURCES..: /etc/ODBCDataSources USER DATA SOURCES..: /Users/emehex/.odbc.ini SQLULEN Size…….: 8 SQLLEN Size……..: 8 SQLSETPOSIROW Size.: 8 Instead of copying the files to the /etc/ directory (not sure why unixODBC thought they were there) I created a symbolic link to each file: … Read more

sql.h not found when installing PyODBC on Heroku

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’)

python pip specify a library directory and an include directory

pip has a –global-option flag You can use it to pass additional flags to build_ext. For instance, to add a –library-dirs (-L) flag: pip install –global-option=build_ext –global-option=”-L/path/to/local” pyodbc gcc supports also environment variables: http://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html I couldn’t find any build_ext documentation, so here is the command line help Options for ‘build_ext’ command: –build-lib (-b) directory for … Read more

Output pyodbc cursor results as python dictionary

If you don’t know columns ahead of time, use Cursor.description to build a list of column names and zip with each row to produce a list of dictionaries. Example assumes connection and query are built: >>> cursor = connection.cursor().execute(sql) >>> columns = [column[0] for column in cursor.description] >>> print(columns) [‘name’, ‘create_date’] >>> results = [] … Read more