iODBC does not work under Mac OSX 10.6.4 - database

I've installed iODBC over the package (http://www.iodbc.org/dataspace/iodbc/wiki/iODBC/) and set up all config files as described here: http://blog.opensteam.net/past/2009/1/28/rails_ms_sql_on_mac/
I set up the same thing on a Linux machine and it worked fine. On my Mac OSX 10.6.4, I get this error if i test the connection:
xxx#xxx:/opt/local/include$ iodbctest "dsn=res;uid=user;pwd=pass"
iODBC Demonstration program
This program shows an interactive SQL processor
Driver Manager: 03.52.0709.0909
1: SQLDriverConnect = [iODBC][Driver Manager]dlopen(/opt/local/lib/libtdsodbc.so, 6): Symbol not found: _CreateDataSource
Referenced from: /usr/lib/libiodbcinst.2.dylib
Expected in: flat namespace
(0) SQLSTATE=00000
2: SQLDriverConnect = [iODBC][Driver Manager]Specified driver could not be loaded (0) SQLSTATE=IM003
I have no idea how to debug this :(

It would be interesting to see what params you have in your odbc.ini and odbcinst.ini files for the DSN and FreeTDS driver being used ?
Looks as if the Apple iODBC Driver Manager is not able to load setup routines required for the driver nor does the FreeTDS driver itself.
The OpenLink iODBC Driver Manager for Mac OS X (which Apples bundled one is based on) is Framework based and does include routines for loading generic setup and login dialogs for those ODBC drivers that do not have built in one. You can download it free (as it is open source) from the following location:
http://www.iodbc.org/downloads/iODBC/iodbc-sdk-3.52.7-macosx-10.5.dmg (it is for 10.5 and 10.6)

Steps to follow:
brew install freetds
subl ~/Library/ODBC/odbc.ini
[sqlserver01]
Driver=/usr/local/lib/libtdsodbc.so
TDS_Version=7.2
Server=192.168.8.7
Port = 1433
Trace = Yes
Description=ds01
# Database=
# can't specify username and password for freetds
subl ~/.freetds.conf
host = ds01.uswa.net # server name
port = 1433
tds version = 8.0 # works with 2008+
sudo pip install pyodbc
sudo pip install sqlsoup
The Python Connection String would look like this:
# Steve is my username; steve is my password; #sqlserver01 is my DSN in odbc.ini
db = sqlsoup.SQLSoup('mssql+pyodbc://Steve:steve#sqlserver01')
The SQLAlchemy way would look like this:
engine = create_engine('mssql+pyodbc://Steve:steve#sqlserver01')`
Do whatever queries…

I had the same problem, linux works, Lion 10.7 not (I guess same problem for 10.6).
I'm using FreeTDS driver to connect, compiling from the source code: it looks like that when compiling, libtdsodbc.so is compiled for the wrong architecture or 32bit/64bit.
I followed this guide (excluding Excel part), and everything worked like a charm.
http://asmiler.blogspot.fr/2011/10/accessing-mssql-databases-from-excel.html

Related

how to setup odbc for MSSQL SERVER correctly

i have made a QT Desktop application as an Appimage. On my development laptop it works fine connecting to the database flawless. But when i put the Appimage to my PC where also the MS SQL Server is hosted it does not work anymore.
My Laptop and PC are Linux Mint 19 Laptop is 19.1 and PC is 19.3 to be specific.
I have installed odbc and tds following this guide:
https://help.interfaceware.com/kb/904
Ubuntu
Run the following commands using a terminal window, or the CLI:
Get the latest package info:
sudo apt-get update
Install libodbc.so, libtdsS.so, isql, and isqlinst:
sudo apt-get install unixodbc
Install libtsdsodbc.so and tsql:
sudo apt-get install tdsodbc
Create a file called odbc.ini
i also edited the /etc/odbc.ini
like this:
Description = MS SQL Server Driver
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
Server = 192.168.0.10
Port = 1433
but when i run the application on the PC i always get:
QSqlError("0", "QODBC3: Unable to connect", "[unixODBC][Driver Manager]Can't open lib 'libtdsodbc.so' : file not found")
i also checked that the library is really under the specified path:
/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
yes it is really there.
so i asking what do i missing here?
help would be really appreciated
best regards
Rolf
I found the solution myself.
I tired to falsify the odbc.ini and the odbcinst.ini on my laptop trying to
reproduce the error there i found that it did took no effect.
After searching for the libtdsodbc.so on the laptop i found it also located at
/usr/local/lib/
so i copied the library from /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so to
/usr/local/lib
and that solved the issue and the QT application is now working fine.

Connect to SQL Server using SQLAlchemy

I'm trying to connect to a SQL Server Express database using SQLALchemy and pyodbc, but I'm continuously getting the error:
(pyodbc.Error) ('IM002', '[IM002] [unixODBC][Driver Manager]Data
source name not found, and no default driver specified (0)
(SQLDriverConnect)')
And I really don't understand if my engine url is wrong or what else.
My scenario is the following:
I'm on a Mac
I have a docker container (based on a Debian image with unixodbc and unixodbc-dev) in which my python app tries to connect to...
a virtualbox virtual machine running windows 8 with SQL express 2014...
I configured a user for the SQL express, with SQL Server authentication:
user: ar_user
password: ar_psw
...then:
I configured TCP ports as 1433 and disabled dynamic ports (SQL Server Configuration Manager > Network Configurations > Protocols).
I turned off Windows Firewall.
I used an Host-only adapter for the VM running windows8
now...
The VM is accessible from the host (my mac), since a:
ping -c 3 vm-ip
succeed!
But although I tried every possible permutation of user, password, ip, server name and port:
'mssql+pyodbc://ar_user:ar_psw#vm-ip/master'
'mssql+pyodbc://ar_user:ar_psw#vm-ip:1433/master'
'mssql+pyodbc://IE10WIN8\\SQLEXPRESS'
'mssql+pyodbc://ar_user:ar_psw#IE10WIN8\\SQLEXPRESS'
'mssql+pyodbc://ar_user:ar_psw#IE10WIN8\\SQLEXPRESS:1433'
'mssql+pyodbc://ar_user:ar_psw#IE10WIN8\\SQLEXPRESS:1433/master'
...and many more!
I always get the "datasource not found error".
What should I do?
ps: the vm is pingable even in the docker container!
UPDATE (solved but not 100%):
I solved in this way:
I configured FreeTDS driver using /etc/odbcinst.ini in this way:
[FreeTDS]
Description = TDS driver (Sybase/MS SQL)
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
client charset = UTF-8
and in /etc/freetds/freetds.conf:
[global]
tds version = 7.3
client charset = UTF-8
Then I created the engine using the following string:
'mssql+pyodbc://my_user:my_psw#machine_ip:1433/my_db?driver=FreeTDS'
It seems to work properly, but I get this warning:
SAWarning: Unrecognized server version info '95.12.255'. Version
specific behaviors may not function properly. If using ODBC with
FreeTDS, ensure TDS_VERSION 7.0 through 7.3, not 4.2, is configured in
the FreeTDS configuration.
I also defined the TDS version using environment variables but it doesn't fix the issue... any idea?
I wrote a tutorial here of how to do this. Essentially, you need to:
brew install unixodbc
brew install freetds --with-unixodbc
Add the freetds driver to odbcinst.ini
Add a DSN (Domain Source Name) to odbc.ini named "MY_DSN"
pip install pyodbc
e = create_engine("mssql+pyodbc://username:password#MY_DSN")
The walkthrough here does a much more thorough job of explaining this, including issues with SQL Server/FreeTDS Protocol Version Compatibility.

Asterisk Realtime Extensions - ODBC Setup

I'm trying to configure Asterisk to read the dialplan for a specific context from my MS-SQL database.
I've followed every step here:
http://www.voip-info.org/wiki/view/Asterisk+RealTime+Extensions
Where though do I enter details of the SQL server, i.e. i've specified I want to use ODBC but where to setup that ODBC connection with servername/user/pass/port etc?
Thanks
You have setup microsoft driver
http://msdn.microsoft.com/en-us/library/hh568451%28v=sql.110%29.aspx
After that change settings of /etc/odbc.ini and /etc/odbcinst.ini
http://www.asteriskdocs.org/en/3rd_Edition/asterisk-book-html-chunk/installing_configuring_odbc.html
Download and install latest version unixODBC
Download and install latest version FreeTDS
Once you have installed this two pakages, you will need to do some
configurations
1- in /etc/odbcinst.ini you need to point to the freetds driver
2 - in /etc/odbc.ini that's where you put your datasource
Example:
[SQLServer]
Driver = FreeTDS
Description = Some Descritpiton
Trace = No
Server = 192.168.1.25
Port = 1433
Database = dbNamehere

Connecting to MS SQL Server with iODBC on Mac

I'm trying to connect to a Microsoft SQL Server from my Mac development machine using iODBC. No matter what I do, I get the error message Unable to connect to data source from the FreeTDS driver. After consulting various manuals, blog posts, and StackOverflow questions, I'm at my wit's end.
I'm using Mac OS X 10.7.4, with FreeTDS version 0.91 installed through Homebrew. Here's what I'm doing:
$ brew install freetds
$ mkvirtualenv odbc
$ workon odbc
$ pip install pyodbc
$ tsql -H localhost -U mydbusername -P mydbpassword -p 1433
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1> quit
The above connects and works, but:
$ iodbctest
iODBC Demonstration program
This program shows an interactive SQL processor
Driver Manager: 03.52.0607.1008
Enter ODBC connect string (? shows list): driver={TDS};server=localhost;uid=mydbusername;pwd=mydbpassword;database=mydbname
1: SQLDriverConnect = [FreeTDS][SQL Server]Unable to connect to data source (0) SQLSTATE=08001
1: ODBC_Connect = [FreeTDS][SQL Server]Unable to connect to data source (0) SQLSTATE=08001
Since I'm ultimately planning to use it through PyODBC, I tried that as well:
$ python
Python 2.7.3 (default, Jun 22 2012, 00:35:38)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyodbc
>>> c = pyodbc.connect(driver='/usr/local/lib/libtdsodbc.so', host='localhost', name='mydbname', uid='mydbusername', pwd='mydbpassword')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
pyodbc.Error: ('08001', '[08001] [FreeTDS][SQL Server]Unable to connect to data source (0) (SQLDriverConnect)')
I've tried all manner of things suggested in blog posts and SO posts... creating DSNs in ODBC Administrator, creating a ~/.odbc.ini, attempting to use unixODBC (which didn't work with PyODBC), specifying a connection string instead of keyword args, etc. I also produced a trace file through iODBC, which I have pasted here, but I couldn't glean any more information from it than from the error message.
(I should mention that I am tunneling the connection to SQL Server over SSH with the line LocalForward localhost:1433 production.someinstitution.edu:1433 in my ~/.ssh/config, since my IT department has limited me to connect only from the production server's IP. It works for a GUI client (SQuirreLSQL) so I assume the forwarding is correct.)
You should use 'port' parameter in connection string in case of DSN-less connection.
Otherwise your port could be specified in your DSN or driver config (odbc.ini and freetds.conf respectively)

How to connect from ruby to MS Sql Server

I'm trying to connect to the sql server 2005 database from *NIX machine:
I have the following configuration: Linux 64bit
ruby -v
ruby 1.8.6 (2007-09-24 patchlevel 111) [x86_64-linux]
important gems:
dbd-odbc (0.2.4)
dbi (0.4.1)
active record sql server adapter - as plugin
ruby-odbc 0.9996 (installed without any options.)
unixODBC is installed
freeTDS is installed
cat /etc/odbcinst.ini
[FreeTDS]
Description = TDS driver (Sybase/MS SQL)
Driver = /usr/lib/libtdsodbc.so
Setup = /usr/lib/odbc/libtdsS.so
CPTimeout =
CPReuse =
FileUsage = 1
DSN:
DRIVER=FreeTDS;TDS_Version=8.0;SERVER=XXXX;DATABASE=XXX;Port=1433;uid=XXX;pwd=XXXX;"
or
DRIVER=/usr/lib/libtdsodbc.so;TDS_Version=8.0;SERVER=XXXX;DATABASE=XXX;Port=1433;uid=XXX;pwd=XXXX;"
I receive the following error:
>>ActiveRecord::Base.sqlserver_connection({"mode"=>"ODBC", "adapter"=>"sqlserver", "dsn"=>my_dns)
DBI::DatabaseError: IM002 (0) [unixODBC][Driver Manager]Data source name not found, and no default driver specified
from /usr/lib/ruby/1.8/DBD/ODBC/ODBC.rb:95:in `connect'
from /usr/lib/ruby/1.8/dbi.rb:424:in `connect'
from /usr/lib/ruby/1.8/dbi.rb:215:in `connect'
from /opt/ublip/rails/current/vendor/plugins/activerecord-sqlserver-adapter/lib/active_record/connection_adapters/sqlserver_adapter.rb:47:in `sqlserver_connection'
It looks like ODBC unable to find appropriate ODBC driver, but I have no ideas why.
I had a problem with /usr/lib/libtdsodbc.so which is empty in default debian package free-tds dev, but i solved it with remove broken package and installation from sources.
Will appreciate any thought!
Note:
I'm albe to connect using the same steps on mac 10.5
This looks close, and I've gotten the same type of setup to work on Ubuntu 8.04 (with Ruby 1.8.6.) Since this is on Debian, it should be the similar.
These packages should be installed: unixodbc unixodbc-dev freetds-dev libdbd-odbc-ruby tdsodbc
/etc/odbcinst.ini should have something like this:
[FreeTDS]
Description = FreeTDS unixODBC Driver
Driver = /usr/lib/odbc/libtdsodbc.so
Setup = /usr/lib/odbc/libtdsodbc.so
UsageCount = 1
And /etc/freetds/freetds.conf: (where XXX is the database name and NNN... is the IP of the server):
[XXX]
host = NNN.NNN.NNN.NNN
tds version = 8.0
client charset = UTF-8
text size = 262144
port = 1433
Then to connect:
ActiveRecord::Base.sqlserver_connection({"mode"=>"ODBC",
"adapter"=>"sqlserver",
"dsn"=>"DRIVER=FreeTDS;SERVERNAME=XXX;DATABASE=XXX;uid=XXX;pwd=XXX"
)

Resources