udara
Posts: 50
Joined: Fri Jul 11, 2014 3:27 pm

How to Connect MS SQL Server From RPi

Sat Jul 26, 2014 5:27 am

I have a computer with MS SQL Server database in my net work and I need to connect it and read data and modify data from RPi. I'm using 2014-06-20-wheezy-raspbian in my RPi and already updated. I install pyodbc using

Code: Select all

sudo apt-get install unixodbc python-pyodbc
I'm using following code,

Code: Select all

import pyodbc

connectionDbServer = pyodbc.connect(driver='{SQL Server}', server='***.***.***.***', database='***', uid='***', pwd='***')
cursorDbServer = connectionDbServer.cursor()
cursorDbServer.execute("xxxxxxx")
cursorDbServerRows = cursorDbServer.fetchall()
print cursorDbServerRows
connectionDbServer.close()
When I execute this code it gives me error saying

Code: Select all

pyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnectW)')
Code is working fine in windows and it retrieve data from DB.
Is there some thing else I need to do in here to make this work please help.
Thanks.

udara
Posts: 50
Joined: Fri Jul 11, 2014 3:27 pm

Re: How to Connect MS SQL Server From RPi

Sun Jul 27, 2014 5:24 am

I also tried to connect using pymssql it seems like it connect to database but it returns a empty data list "[]"
pymssql 1.0.2 and I cannot update this to 2.0 because it requires "setuptools-0.6c9-py2.7.egg" and I cant find it out, I cant figure out the issue please help.
Thanks

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: How to Connect MS SQL Server From RPi

Sun Jul 27, 2014 2:29 pm

I can't offer any personal help, but have you looked through http://www.raspberrypi.org/forums/searc ... ords=mssql ?

udara
Posts: 50
Joined: Fri Jul 11, 2014 3:27 pm

Re: How to Connect MS SQL Server From RPi

Mon Jul 28, 2014 2:54 pm

Thanks.
I tried to create the connection by editing these files,
/etc/odbc.ini
/etc/odbcinst.ini
/etc/freetds/freetds.conf
but it didn't work. I think it is better to use MySQL for database because it can configure very easily.
Thanks.

Return to “Beginners”