1
votes

I'm using freetds 0.95 on mac os x (yosemite) to connect to SQL server [want to connect to local db] but all of my attempts have failed so far.

odbcinst -j on terminal gives me the following:

unixODBC 2.3.2
DRIVERS............: /usr/local/Cellar/unixodbc/2.3.2_1/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/Cellar/unixodbc/2.3.2_1/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/Cellar/unixodbc/2.3.2_1/etc/ODBCDataSources
USER DATA SOURCES..: /Users/user/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

Initially, I want to connect to my local sql server.

Below is an extract of my freetds.conf located at /usr/local/etc/freetds.conf

# A typical Microsoft server
[#egServer70]
#   host = ntmachine.domain.com
#   port = 1433
#   tds version = 7.0
    [TITAN]
    host = 127.0.0.1
    port = 3306
    tds version = 8.0

    [testing]
    host = 127.0.0.1
    port = 1433
    tds version = 8.0

I have tried to use TDS Version 8.0 but the connection still fails.

When I run either tsql -S TITAN -U root or tsql -S testing -U root, I get the following error:

locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Error 20002 (severity 9):
    Adaptive Server connection failed
There was a problem connecting to the server

Below are:

odbcinst.ini file located at /usr/local/Cellar/unixodbc/2.3.2_1/etc

[FreeTDS]
Description=Open source FreeTDS Driver
Driver=/usr/local/lib/libtdsodbc.so
UsageCount=1

odbc.ini file located at /usr/local/Cellar/unixodbc/2.3.2_1/etc

[testing]
Driver=FreeTDS
Server=localhost
#Port=3306
#charset=UTF8 
User=
Password=
#Database=admin
## can specify an actual database to each DSN
TDS_Version=8.0
[Default]
Driver=/usr/local/lib/libtdsodbc.so

I don't really know what I have done wrong so far, maybe I have wrongly installed the odbc on the os, freetds. Please help me sort this out.

1
You're on Mac OS/X but you want to connect to Microsoft SQL Server locally? SQL Server from Microsoft only runs on Windows (for now), so you can't connect to it locally short of running Windows in a VM, but that's a whole different can of worms.FlipperPA
I have installed MySQL on Max OS using Native packages. dev.mysql.com/doc/refman/5.7/en/osx-installation-pkg.htmluser2841451
SQL runs fine. I experience connection issues when I try to connect to postgres as well. I believe that I have wrongly installed or configured odbc/freetds.user2841451
Installing MySQL has nothing to do with SQL Server. Those are 2 completely different things.James Z
MySQL is NOT SQL Server; SQL Server is the database server from Microsoft. Therein lies the confusion. FreeTDS is used to connect to Microsoft SQL Server. I'll give an answer.FlipperPA

1 Answers

1
votes

The problem from here is some confusion.

Microsoft SQL Server is a product that runs only on Windows (for now) that you can connect to over ODBC with unixODBC and FreeTDS. You don't need this.

Since you're connecting to MySQL, you need a Python package to connect to it. I would recommend this package, as it is compatible with Python 2 & 3 and recommended by Django's documentation:

https://pypi.python.org/pypi/mysqlclient

Give that a try. Good luck!