Using mxodbc with SQL Server 2012
John Anderson <[email protected]> Wed, 2 Sep 2015 11:36:51 -0700
| Newsgroups | gmane.comp.python.egenix.user |
|---|---|
| Message-ID | <CAOdFaDXon5daeca5mj2hiDQcjkVXfWtf5QuG+LFOjSXuUi7JNg@mail.gmail.com> |
--===============41617033060291764==
Content-Type: multipart/alternative; boundary=94eb2c0541b633e209051ec7f3cc
--94eb2c0541b633e209051ec7f3cc
Content-Type: text/plain; charset=UTF-8
Hey, We currently use pymssql and it was recommended that we checkout
mxODBC again (its been a few years) and even though most of our projects
require python 3 we have a few legacy python applications that are still on
python 2.7 so I thought I would give it a try.
I'm currently getting this error:
mx.ODBC.Error.OperationalError: ('08003', 0, '[unixODBC][Driver
Manager]Connnection does not exist', 13710)
with this code:
import mx.ODBC.unixODBC as mx
db = mx.DriverConnect('DSN=mt1;UID=<secret>;PWD=<secret>')
c = db.cursor()
c.tables()
res = c.fetchall()
and I'm wondering might cause that because I can use isql/tsql and it works:
tsql -S mt1 -U <secret> -P <secret>
isql mt1 <secret> <secret>
osql is the only one that doesn't work:
osql -S mt1 -U <secret> -P <secret>
checking shared odbc libraries linked to isql for default directories...
strings: '': No such file
trying /tmp/sql ... no
trying /tmp/sql ... no
trying /etc ... OK
checking odbc.ini files
reading /home/sontek/.odbc.ini
[mt1] not found in /home/sontek/.odbc.ini
reading /etc/odbc.ini
[mt1] found in /etc/odbc.ini
found this section:
[mt1]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
Trace = Yes
TraceFile = /tmp/sql.log
ServerName = mt1
Database = SM_AccountsNew
looking for driver for DSN [mt1] in /etc/odbc.ini
found driver line: " Driver = FreeTDS"
driver "FreeTDS" found for [mt1] in odbc.ini
found driver named "FreeTDS"
"FreeTDS" is not an executable file
looking for entry named [FreeTDS] in /etc/odbcinst.ini
found driver line: " Driver =
/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so"
found driver /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so for [FreeTDS]
in odbcinst.ini
/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so is not an executable file
osql: error: no driver found for mt1
Anyone know what I might be missing?
Here is my FreeTDS:
[mt1]
host = mt1-db01.corp.surveymonkey.com
port = 1433
tds version = 7.3
client charset = UTF-8
odbc.ini:
[mt1]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
Trace = Yes
TraceFile = /tmp/sql.log
ServerName = mt1
Database = SM_AccountsNew
odbcinst.ini:
[FreeTDS]
Description = TDS
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Startup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
UsageCount = 1
Threading = 2
--94eb2c0541b633e209051ec7f3cc
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_quote"><div dir=3D"ltr">Hey, We curren=
tly use pymssql and it was recommended that we checkout mxODBC again (its b=
een a few years) and even though most of our projects require python 3 we h=
ave a few legacy python applications that are still on python 2.7 so I thou=
ght I would give it a try.<div><br></div><div>I'm currently getting thi=
s error:</div><div><br></div><div><div>mx.ODBC.Error.OperationalError: (=
9;08003', 0, '[unixODBC][Driver Manager]Connnection does not exist&=
#39;, 13710)</div></div><div><br></div><div>with this code:</div><div><br><=
/div><div><div>import mx.ODBC.unixODBC as mx</div><div>db =3D mx.DriverConn=
ect('DSN=3Dmt1;UID=3D<secret>;PWD=3D<secret>')</div><di=
v>c =3D db.cursor()</div><div>c.tables()</div><div>res =3D c.fetchall()</di=
v></div><div><br></div><div>and I'm wondering might cause that because =
I can use isql/tsql and it works:</div><div><br></div><div>tsql -S mt1 -U &=
lt;secret> -P <secret><br></div><div>isql mt1 <secret> <s=
ecret><br></div><div><br></div><div>osql is the only one that doesn'=
t work:</div><div><br></div><div><br></div><div><div>osql -S mt1 -U <sec=
ret> -P <secret></div><div><br></div><div>checking shared odbc lib=
raries linked to isql for default directories...</div><div>strings: '&#=
39;: No such file</div><div><span style=3D"white-space:pre-wrap"> </span>tr=
ying /tmp/sql ... no</div><div><span style=3D"white-space:pre-wrap"> </span=
>trying /tmp/sql ... no</div><div><span style=3D"white-space:pre-wrap"> </s=
pan>trying /etc ... OK</div><div>checking odbc.ini files</div><div><span st=
yle=3D"white-space:pre-wrap"> </span>reading /home/sontek/.odbc.ini</div><d=
iv>[mt1] not found in /home/sontek/.odbc.ini</div><div><span style=3D"white=
-space:pre-wrap"> </span>reading /etc/odbc.ini</div><div>[mt1] found in /et=
c/odbc.ini</div><div>found this section:</div><div><span style=3D"white-spa=
ce:pre-wrap"> </span>[mt1]</div><div><span style=3D"white-space:pre-wrap"> =
</span>Driver =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D FreeTDS</div><div><span=
style=3D"white-space:pre-wrap"> </span>Description =C2=A0 =C2=A0 =3D ODBC =
connection via FreeTDS</div><div><span style=3D"white-space:pre-wrap"> </sp=
an>Trace =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D Yes</div><div><span style=
=3D"white-space:pre-wrap"> </span>TraceFile =C2=A0 =C2=A0 =C2=A0 =3D /tmp/s=
ql.log</div><div><span style=3D"white-space:pre-wrap"> </span>ServerName =
=C2=A0 =C2=A0 =C2=A0=3D mt1</div><div><span style=3D"white-space:pre-wrap">=
</span>Database =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D SM_AccountsNew</div><div>lo=
oking for driver for DSN [mt1] in /etc/odbc.ini</div><div>=C2=A0 found driv=
er line: "<span style=3D"white-space:pre-wrap"> </span>Driver =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0=3D FreeTDS"</div><div>=C2=A0 driver "=
FreeTDS" found for [mt1] in odbc.ini</div><div>found driver named &quo=
t;FreeTDS"</div><div>"FreeTDS" is not an executable file</di=
v><div>looking for entry named [FreeTDS] in /etc/odbcinst.ini</div><div>=C2=
=A0 found driver line: "<span style=3D"white-space:pre-wrap"> </span>D=
river =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D /usr/lib/x86_64-linux-gnu/odbc/=
libtdsodbc.so"</div><div>=C2=A0 found driver /usr/lib/x86_64-linux-gnu=
/odbc/libtdsodbc.so for [FreeTDS] in odbcinst.ini</div><div>/usr/lib/x86_64=
-linux-gnu/odbc/libtdsodbc.so is not an executable file</div><div>osql: err=
or: no driver found for mt1</div></div><div><br></div><div><br></div><div>A=
nyone know what I might be missing?</div><div><br></div><div>Here is my Fre=
eTDS:</div><div><br></div><div><div>[mt1]</div><div>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 host =3D <a href=3D"http://mt1-db01.corp.surveymonkey.com" target=3D=
"_blank">mt1-db01.corp.surveymonkey.com</a></div><div>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 port =3D 1433</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 tds version =3D =
7.3</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 client charset =3D UTF-8</div></d=
iv><div><br></div><div>odbc.ini:</div><div><br></div><div><div>[mt1]</div><=
div>Driver =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D FreeTDS</div><div>Descript=
ion =C2=A0 =C2=A0 =3D ODBC connection via FreeTDS</div><div>Trace =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D Yes</div><div>TraceFile =C2=A0 =C2=A0 =C2=
=A0 =3D /tmp/sql.log</div><div>ServerName =C2=A0 =C2=A0 =C2=A0=3D mt1</div>=
<div>Database =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D SM_AccountsNew</div></div><div=
><br></div><div><br></div><div>odbcinst.ini:</div><div><div>[FreeTDS]</div>=
<div>Description =C2=A0 =C2=A0 =3D TDS</div><div>Driver =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0=3D /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so</div><div=
>Startup =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D /usr/lib/x86_64-linux-gnu/odbc/lib=
tdsS.so</div><div>UsageCount =C2=A0 =C2=A0 =C2=A0=3D 1</div><div>Threading =
=C2=A0 =C2=A0 =C2=A0 =3D 2</div></div><div><br></div><div><br></div></div>
</div><br></div>
--94eb2c0541b633e209051ec7f3cc--
--===============41617033060291764==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
_______________________________________________________________________
eGenix.com User Mailing List http://www.egenix.com/
https://www.egenix.com/mailman/listinfo/egenix-users
--===============41617033060291764==--