[egenix-users] mx.odbc segmentation fault on fetching string

Wouter van Atteveldt wouter at 2at.nl
Tue Jun 3 03:49:58 CEST 2008

Dear list,

I am evaluating mx.odbc for connecting to a MS SQL server from my Linux machine using freetds 0.82. I can connect and query using isql without problem, but I get a segmentation fault if I fetch using the mx.odbc interface.

wva at amcat:~/tmp$ isql -v AmcatDB <UID> <PWD>
| Connected!
SQL> select top 1 projectid, name from projects
| 1          | test
SQLRowCount returns 1
1 rows fetched

wva at amcat:~/tmp$ python testodbc.py
connected to Microsoft SQL Server 08.00.2039
Executed, fetching...
Executed, fetching...
Segmentation fault

wva at amcat:~/tmp$ cat testodbc.py
import mx.ODBC
db = mx.ODBC.unixODBC.connect("AmcatDB", "<UID>", "<PWD>")
print "connected to %s %s" % (db.dbms_name, db.dbms_version)
c = db.cursor()
c.executedirect("select top 1 projectid from projects")
print "Executed, fetching..."
print c.fetchall()
c.executedirect("select top 1 projectid, name from projects")
print "Executed, fetching..."

print c.fetchall()wva at amcat:~/tmp$ uname -a
Linux amcat 2.6.18-6-amd64 #1 SMP Sun Feb 10 17:50:19 UTC 2008 x86_64
wva at amcat:~/tmp$ python -c "import sys;print(sys.maxunicode<66000)and'UCS2'or'UCS4'"

As you can see, it returns the MS SQL version number so it has some contact with the remote db. I installed using egenix-mxodbc-3.0.1.linux-x86_64-py2.5_ucs4.prebuilt.zip, which I think should be OK as x86_64 == AMD64 (right?). projected is int, name is a varchar(255) column, and the table should have a couple hundred entries at most.

The relevant etc files:

wva at amcat:~/tmp$ tail -4 /usr/local/freetds/etc/freetds.conf
        host = localhost
        port = 1433
        tds version = 8.0
wva at amcat:~/tmp$ cat /etc/odbc.ini
Driver          = FreeTDS
Description             = amcatdb MS SQL Database
Trace           = No
Servername              = amcatdb
Database                = anoko
wva at amcat:~/tmp$ cat /etc/odbcinst.ini
Description             = v0.63 with protocol v8.0
Driver          = /usr/local/freetds/lib/libtdsodbc.so
UsageCount              = 1

Note that I am using an SSH tunnel to connect to the sql server, hence the localhost. This does not give trouble using either tsql, isql, or python-sybase (on a previous install), so I am not expecting this to be the cause of the problem.

Any help greatly appreciated!

-- Wouter

More information about the egenix-users mailing list