1

I'm at a loss here. I'm very new to python and odbc in general. However I need to find a way to have a python script in the backend of a web gui for an internal tool for my company, communicate with MSSQL server from: 1. my local mac os machine, 2.a linux server that hosts all of our internal tools.

I have tried installing freetds and configuring it as show: http://blog.nguyenvq.com/blog/2013/04/06/guide-to-accessing-ms-sql-server-and-mysql-server-on-mac-os-x/

but I'm getting issues with driver not being located where the tutorial specifies after installing freetds.

I'm not quite sure where to even start with troubleshooting.

Can anyone give me a place to start with possibly making this work? It seemed to me python was going to be my best bet with this, but if there are other, better options -- I'm certainly open to them.

Thanks so much, I apologize for how open ended this is, but I'm not sure where to start. Every resource I'm finding is either miles over my head, or is too ambiguous to follow.

2
  • What specific trouble are you having? Do you get an error message when trying to run some code? If so, post the error message (and the error traceback information). Commented Nov 17, 2015 at 18:57
  • Running tsql -C should let you know where FreeTDS installed, as well as some other information. Commented Nov 19, 2015 at 18:08

1 Answer 1

1

I'm not sure how to handle the OSx part of this, but you might be able to do something similar.

I have successfully used pyodbc (https://code.google.com/p/pyodbc/) to connect to SQL Server 2008.

Steps for RHEL/CentOS 6 (taken from http://funwithlinux.net/2013/07/connect-to-sql-server-with-python/)

1)Enable the EPEL

2)Install the Required Packages

yum install gcc gcc-c++ python-devel freetds unixODBC unixODBC-devel

3)Download latest stable version of pyodbc

4)Unzip, then build and install pyodbc with the following command:

python setup.py build install

5)edit /etc/odbcinst.ini to include the following:

[FreeTDS]
Driver = /usr/lib64/libtdsodbc.so.0
UsageCount = 1

6)Test with the following example (modified to your needs, obviously):

import pyodbc

cnxn = pyodbc.connect('DRIVER={FreeTDS};SERVER=dev-sql02;PORT=1433;UID=EXAMPLE\\myusero;PWD=xxx;DATABASE=fx_staging;UseNTLMv2=yes;TDS_Version=8.0;Trusted_Domain=EXAMPLE;')
cursor = cnxn.cursor()
cursor.execute("select state, zip from addresses")
row = cursor.fetchone()
if row:
    print row
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.