I'm trying to connect a raspberry pi 3 to a local SQL Server.
I did this:
sudo apt-get install unixodbc
sudo apt-get install unixodbc-dev
sudo apt-get install freetds-dev
sudo apt-get install tdsodbc
sudo apt-get install freetds-bin
sudo pip3 install pyodbc
sudo apt-get install python-pyodbc
sudo nano /etc/freetds/freetds.conf
Added this block
[sqlserver]
host = 192.168.0.109 # Sql Server's IP addr
port = 1433 # default
tds version = 7.0 #
instance = Database1 # Database name
now in /etc/odbcinst.ini
[FreeTDS]
Description = FreeTDS unixODBC Driver
Driver = /usr/lib/arm-linux-gnueabihf/odbc/libtdsodbc.so
Setup = /usr/lib/arm-linux-gnueabihf/odbc/libtdsodbc.so
UsageCount = 1
and in /etc/odbc.ini
file as follows:
[NAME1]
Driver = /usr/lib/arm-linux-gnueabihf/odbc/libtdsodbc.so
Description = MSSQL Server
Trace = No
Server = ServerName1
Database = Database 1
Port = 1433
TDS_Version = 7.4
when I run
tsql -S sqlserver -U username
I can connect t the database and run queries, but When I try
tsql isql NAME1 user 'password'
I get
[ISQL]ERROR: Could not SQLConnect
I got a python script with
class SQL:
cnxn = None
cursor= None
def __init__(self):
try:
self.cnxn = pyodbc.connect('DRIVER={FreeTDS}; SERVER= ws2016_01; DATABASE=databasename; UID=user; PWD=password;TDS_Version=7.2;')
self.cnxn.setdecoding(pyodbc.SQL_CHAR, encoding='utf-8')
self.cnxn.setdecoding(pyodbc.SQL_WCHAR, encoding='utf-8')
self.cnxn.setencoding(encoding='utf-8')
And I keep getting the error
[08001] [FreeTDS][SQL Server]Unable to connect to data source (0) (SQLDriverConnect)
Thanks for reading, any help would be deeply appreciated!