From: Michał S. <mi...@sa...> - 2011-01-25 21:43:43
|
Hi, I'm trying to get Python to work with a ASA 9.0.1 server and having not much luck... Just to confirm the server's working and such, the following in Perl works fine: DBI->connect('DBI:Sybase:server=asademo;database=asademo', 'DBA', 'SQL'); First I tried python-mssql as it's supposed to work with Sybase, too, but I couldn't get connected to the database at all, getting "Could not set connection properties" errors when I was able to connect at last. I also tried tsql itself, which seemed to connect (I got a 1> prompt) but regardless of what query I tried to execute, I got no response, dropping me to another prompt (2>). After some googling I found out that I should be using python-sybase. I tried both 0.39 and 0.40pre1, yielding the same results: > ctx.c:242: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or > ‘__attribute__’ before ‘clientmsg_cb’ > ctx.c:287: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or > ‘__attribute__’ before ‘servermsg_cb’ > ctx.c: In function ‘CS_CONTEXT_ct_callback’: > ctx.c:364: error: ‘clientmsg_cb’ undeclared (first use in this > function) > ctx.c:364: error: (Each undeclared identifier is reported only > once > ctx.c:364: error: for each function it appears in.) > ctx.c:370: error: ‘servermsg_cb’ undeclared (first use in this > function) > error: command 'gcc' failed with exit status 1 when built without -DHAVE_FREETDS. It built and installed fine with either of -DHAVE_FREETDS and -DHAVE_FREETDS=82 (I've freetds 0.82 from Debian lenny), but then trying to import the Sybase module results in: > /usr/local/lib/python2.6/dist-packages/python_sybase-0.39-py2.6-linux-i686.egg/sybasect.so: undefined symbol: cs_config And now I give up :/ Am I doing something wrong or do I simply have to drop that and go some other route? Best regards, -- Michał Sawicz <mi...@sa...> |
From: Michał S. <mi...@sa...> - 2011-01-25 22:03:29
|
Dnia 2011-01-25, wto o godzinie 15:49 -0600, Robert Boehne pisze: > Michał Sawicz wrote: > > I also tried tsql itself, which seemed to connect (I got a 1> prompt) > > but regardless of what query I tried to execute, I got no response, > > dropping me to another prompt (2>). > > > did you type "go" at the 2nd prompt and hit <Enter> ? Right, new to Sybase, thanks for that - it worked. > It sounds like you're not specifying the right arguments to allow these > pieces of software to connect to the server. > Normally, you need a hostname, port, username and password. How you > combine those to get a connection would depend on the specific software > you're using. > > Post the details of how you create the connection - better yet - try and > connect with explicit arguments, after you make sure you know what to > set where. OK, so: > tsql -S asademo -U DBA works. But in python, either of: > conn = pymssql.connect(host='asademo', user='DBA', password='SQL', > database='asademo') > conn = pymssql.connect(host='asademo', user='DBA', password='SQL') result in: > --------------------------------------------------------------------------- > InterfaceError Traceback (most recent call last) > > /root/<ipython console> in <module>() > > /usr/lib/pymodules/python2.6/pymssql.pyc in connect(dsn, user, password, host, database, timeout, login_timeout, trusted, charset, as_dict, max_conn) > 607 raise OperationalError, e[0] > 608 except _mssql.MssqlDriverException, e: > --> 609 raise InterfaceError, e[0] > 610 > 611 # default query timeout > > > InterfaceError: Could not set connection properties Using dsn: > conn = pymssql.connect(dsn='asademo', user='DBA', password='SQL', > database='asademo') or > conn = pymssql.connect(dsn='asademo', user='DBA', password='SQL') both yield: > --------------------------------------------------------------------------- > InterfaceError Traceback (most recent call last) > > /root/<ipython console> in <module>() > > /usr/lib/pymodules/python2.6/pymssql.pyc in connect(dsn, user, password, host, database, timeout, login_timeout, trusted, charset, as_dict, max_conn) > 607 raise OperationalError, e[0] > 608 except _mssql.MssqlDriverException, e: > --> 609 raise InterfaceError, e[0] > 610 > 611 # default query timeout > > > InterfaceError: Connection to the database failed for an unknown reason. Hope that clears things up... BTW, here's a relevant part of my freetds.conf: > [asademo] > host = 127.0.0.1 > port = 2638 > tds version = 5.0 > dump file = /tmp/freetds.log > debug flags = 0xffff I can provide the freetds.log file, if it would help, of course. Thanks for the fast response, -- Michał Sawicz <mi...@sa...> |
From: Michał S. <mi...@sa...> - 2011-01-25 22:29:32
|
Dnia 2011-01-25, wto o godzinie 23:00 +0100, Michał Sawicz pisze: > > InterfaceError: Could not set connection properties Looking at pymssql code [1] I can only assume that the module won't work for Sybase (at least for my version), simply because it seems not to support some of these properties. So I'm getting connected but the connection properties that pymssql is trying to set don't go through. So I need to have python-sybase working... [1] http://code.google.com/p/pymssql/source/browse/trunk/_mssql.pyx#482 Best regards, -- Michał Sawicz <mi...@sa...> |
From: Robert B. <ro...@tr...> - 2011-01-25 22:11:02
|
Michał Sawicz wrote: > Hi, I'm trying to get Python to work with a ASA 9.0.1 server and having > not much luck... > > Just to confirm the server's working and such, the following in Perl > works fine: > > DBI->connect('DBI:Sybase:server=asademo;database=asademo', 'DBA', > 'SQL'); > > First I tried python-mssql as it's supposed to work with Sybase, too, > but I couldn't get connected to the database at all, getting "Could not > set connection properties" errors when I was able to connect at last. > > I also tried tsql itself, which seemed to connect (I got a 1> prompt) > but regardless of what query I tried to execute, I got no response, > dropping me to another prompt (2>). > did you type "go" at the 2nd prompt and hit <Enter> ? > After some googling I found out that I should be using python-sybase. I > tried both 0.39 and 0.40pre1, yielding the same results: > > > >> ctx.c:242: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or >> ‘__attribute__’ before ‘clientmsg_cb’ >> ctx.c:287: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or >> ‘__attribute__’ before ‘servermsg_cb’ >> ctx.c: In function ‘CS_CONTEXT_ct_callback’: >> ctx.c:364: error: ‘clientmsg_cb’ undeclared (first use in this >> function) >> ctx.c:364: error: (Each undeclared identifier is reported only >> once >> ctx.c:364: error: for each function it appears in.) >> ctx.c:370: error: ‘servermsg_cb’ undeclared (first use in this >> function) >> error: command 'gcc' failed with exit status 1 >> > > when built without -DHAVE_FREETDS. It built and installed fine with > either of -DHAVE_FREETDS and -DHAVE_FREETDS=82 (I've freetds 0.82 from > Debian lenny), but then trying to import the Sybase module results in: > > >> /usr/local/lib/python2.6/dist-packages/python_sybase-0.39-py2.6-linux-i686.egg/sybasect.so: undefined symbol: cs_config >> > > And now I give up :/ > > Am I doing something wrong or do I simply have to drop that and go some > other route? > > Best regards, > It sounds like you're not specifying the right arguments to allow these pieces of software to connect to the server. Normally, you need a hostname, port, username and password. How you combine those to get a connection would depend on the specific software you're using. Post the details of how you create the connection - better yet - try and connect with explicit arguments, after you make sure you know what to set where. HTH, Robert |
From: Robert B. <ro...@tr...> - 2011-01-25 22:35:16
|
Michał Sawicz wrote: > Dnia 2011-01-25, wto o godzinie 15:49 -0600, Robert Boehne pisze: > >> Michał Sawicz wrote: >> >>> I also tried tsql itself, which seemed to connect (I got a 1> prompt) >>> but regardless of what query I tried to execute, I got no response, >>> dropping me to another prompt (2>). >>> >>> >> did you type "go" at the 2nd prompt and hit <Enter> ? >> > > Right, new to Sybase, thanks for that - it worked. > > Great! Let's focus on that. Below you're letting some of the arguments default, like the password and database, but when you use pymssql you have explicitly set them. Can you still connect when you use those same arguments with the tsql command line? >> tsql -S asademo -U DBA >> > > works. > > But in python, either of: > > >> conn = pymssql.connect(host='asademo', user='DBA', password='SQL', >> database='asademo') >> |
From: Michał S. <mi...@sa...> - 2011-01-25 22:50:59
|
Dnia 2011-01-25, wto o godzinie 16:35 -0600, Robert Boehne pisze: > Great! Let's focus on that. Below you're letting some of the > arguments default, like the password and database, but when you use > pymssql you have explicitly set them. > Can you still connect when you use those same arguments with the tsql > command line? It works like so: > $ tsql -S asademo -U DBA -P SQL > locale is "pl_PL.UTF-8" > locale charset is "UTF-8" > 1> But not with the database set: > $ tsql -S asademo -U DBA -P SQL -D asademo > locale is "pl_PL.UTF-8" > locale charset is "UTF-8" > Default database being set to asademo > Msg 102, Level 15, State 0, Server , Line 0 > ASA Error -131: Syntax error near 'use' on line 1 > There was a problem connecting to the server I suppose that's correct since AFAIK Sybase only has one database per server, so no database selection can take place. The exact same arguments to _mssql.connect(): > conn = _mssql.connect(server='asademo', user='DBA', password='SQL') > MssqlDriverException: Could not set connection properties And, as I wrote in the other e-mail, that's probably to be expected with pymssql trying to connect to (an old) sybase. Best regards, -- Michał Sawicz <mi...@sa...> |
From: Michał S. <mi...@sa...> - 2011-01-25 23:20:39
|
Dnia 2011-01-25, wto o godzinie 23:48 +0100, Michał Sawicz pisze: > And, as I wrote in the other e-mail, that's probably to be expected > with pymssql trying to connect to (an old) sybase. I've confirmed that: > 1> SET ARITHABORT ON; > 2> go > 1> SET CONCAT_NULL_YIELDS_NULL ON; > 2> go > Msg 102, Level 15, State 0, Server , Line 0 > ASA Error -131: Syntax error near 'CONCAT_NULL_YIELDS_NULL' on line 1 > 1> SET ANSI_NULLS ON > 2> go > 1> SET ANSI_NULL_DFLT_ON ON; > 2> go > Msg 102, Level 15, State 0, Server , Line 0 > ASA Error -131: Syntax error near 'ANSI_NULL_DFLT_ON' on line 1 > 1> SET ANSI_PADDING ON; > 2> go > Msg 102, Level 15, State 0, Server , Line 0 > ASA Error -131: Syntax error near 'ANSI_PADDING' on line 1 > 1> SET ANSI_WARNINGS ON; > 2> go > Msg 102, Level 15, State 0, Server , Line 0 > ASA Error -131: Syntax error near 'ANSI_WARNINGS' on line 1 > 1> SET ANSI_NULL_DFLT_ON ON; > 2> go > Msg 102, Level 15, State 0, Server , Line 0 > ASA Error -131: Syntax error near 'ANSI_NULL_DFLT_ON' on line 1 > 1> SET CURSOR_CLOSE_ON_COMMIT ON; > 2> go > Msg 102, Level 15, State 0, Server , Line 0 > ASA Error -131: Syntax error near 'CURSOR_CLOSE_ON_COMMIT' on line 1 > 1> SET QUOTED_IDENTIFIER ON; > 2> go > 1> SET IMPLICIT_TRANSACTIONS ON; > 2> go > Msg 102, Level 15, State 0, Server , Line 0 > ASA Error -131: Syntax error near 'IMPLICIT_TRANSACTIONS' on line 1 As you can see most of the SET commands from _mssql fail. So I'm left with python-sybase for good... I could patch pymssql probably, but I'd rather not. -- Michał Sawicz <mi...@sa...> |
From: Robert B. <ro...@tr...> - 2011-01-25 23:46:59
|
MSSQL will let you set the TDS version you use when you connect. To my knowledge, when you have things set up correctly, you can connect to any version of Sybase. You may be using a TDS version that Sybase doesn't understand, if so you'd need to dumb it down to something lower. Regardless, if you're connecting to Sybase, you'll be better off with python-sybase. Now, what problem were you having connecting with it? > > when built without -DHAVE_FREETDS. It built and installed fine with > either of -DHAVE_FREETDS and -DHAVE_FREETDS=82 (I've freetds 0.82 from > Debian lenny), but then trying to import the Sybase module results in: > > >> > /usr/local/lib/python2.6/dist-packages/python_sybase-0.39-py2.6-linux-i686.egg/sybasect.so: undefined symbol: cs_config >> This symbol is defined by the ct library from Sybase, in your case you're replacing that with the freetds version. So, you may not have linked to freetds properly, or you may just need to add the directory where your freetds binaries are to LD_LIBRARY_PATH. Michał Sawicz wrote: > Dnia 2011-01-25, wto o godzinie 23:48 +0100, Michał Sawicz pisze: > >> And, as I wrote in the other e-mail, that's probably to be expected >> with pymssql trying to connect to (an old) sybase. >> > > I've confirmed that: > > >> 1> SET ARITHABORT ON; >> 2> go >> 1> SET CONCAT_NULL_YIELDS_NULL ON; >> 2> go >> Msg 102, Level 15, State 0, Server , Line 0 >> ASA Error -131: Syntax error near 'CONCAT_NULL_YIELDS_NULL' on line 1 >> 1> SET ANSI_NULLS ON >> 2> go >> 1> SET ANSI_NULL_DFLT_ON ON; >> 2> go >> Msg 102, Level 15, State 0, Server , Line 0 >> ASA Error -131: Syntax error near 'ANSI_NULL_DFLT_ON' on line 1 >> 1> SET ANSI_PADDING ON; >> 2> go >> Msg 102, Level 15, State 0, Server , Line 0 >> ASA Error -131: Syntax error near 'ANSI_PADDING' on line 1 >> 1> SET ANSI_WARNINGS ON; >> 2> go >> Msg 102, Level 15, State 0, Server , Line 0 >> ASA Error -131: Syntax error near 'ANSI_WARNINGS' on line 1 >> 1> SET ANSI_NULL_DFLT_ON ON; >> 2> go >> Msg 102, Level 15, State 0, Server , Line 0 >> ASA Error -131: Syntax error near 'ANSI_NULL_DFLT_ON' on line 1 >> 1> SET CURSOR_CLOSE_ON_COMMIT ON; >> 2> go >> Msg 102, Level 15, State 0, Server , Line 0 >> ASA Error -131: Syntax error near 'CURSOR_CLOSE_ON_COMMIT' on line 1 >> 1> SET QUOTED_IDENTIFIER ON; >> 2> go >> 1> SET IMPLICIT_TRANSACTIONS ON; >> 2> go >> Msg 102, Level 15, State 0, Server , Line 0 >> ASA Error -131: Syntax error near 'IMPLICIT_TRANSACTIONS' on line 1 >> > > As you can see most of the SET commands from _mssql fail. So I'm left > with python-sybase for good... I could patch pymssql probably, but > I'd rather not. > > |
From: Michał S. <mi...@sa...> - 2011-01-26 00:05:18
|
Dnia 2011-01-25, wto o godzinie 17:46 -0600, Robert Boehne pisze: > This symbol is defined by the ct library from Sybase, in your case > you're replacing that with the freetds version. > So, you may not have linked to freetds properly, or you may just need > to add the directory where your freetds binaries are to > LD_LIBRARY_PATH. I suppose the linking's wrong - libct.so iBs missing: > $ ldd /usr/local/lib/python2.6/dist-packages/python_sybase-0.40pre1-py2.6-linux-i686.egg/sybasect.so > linux-gate.so.1 => (0xffffe000) > libpthread.so.0 => /lib/libpthread.so.0 (0xb8017000) > libc.so.6 => /lib/libc.so.6 (0xb7ed1000) > /lib/ld-linux.so.2 (0xb8053000) But that suggests it's a problem in setup.py, no? here's a log from build_ext: > $ python setup.py build_ext -DHAVE_FREETDS > running build_ext > building 'sybasect' extension > creating build > creating build/temp.linux-i686-2.6 > gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_FREETDS=1 -I/opt/sybase/SYBSsa9/include -I/usr/include/python2.6 -c blk.c -o build/temp.linux-i686-2.6/blk.o > gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_FREETDS=1 -I/opt/sybase/SYBSsa9/include -I/usr/include/python2.6 -c databuf.c -o build/temp.linux-i686-2.6/databuf.o > gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_FREETDS=1 -I/opt/sybase/SYBSsa9/include -I/usr/include/python2.6 -c cmd.c -o build/temp.linux-i686-2.6/cmd.o > gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_FREETDS=1 -I/opt/sybase/SYBSsa9/include -I/usr/include/python2.6 -c conn.c -o build/temp.linux-i686-2.6/conn.o > gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_FREETDS=1 -I/opt/sybase/SYBSsa9/include -I/usr/include/python2.6 -c ctx.c -o build/temp.linux-i686-2.6/ctx.o > gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_FREETDS=1 -I/opt/sybase/SYBSsa9/include -I/usr/include/python2.6 -c datafmt.c -o build/temp.linux-i686-2.6/datafmt.o > gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_FREETDS=1 -I/opt/sybase/SYBSsa9/include -I/usr/include/python2.6 -c iodesc.c -o build/temp.linux-i686-2.6/iodesc.o > gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_FREETDS=1 -I/opt/sybase/SYBSsa9/include -I/usr/include/python2.6 -c locale.c -o build/temp.linux-i686-2.6/locale.o > gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_FREETDS=1 -I/opt/sybase/SYBSsa9/include -I/usr/include/python2.6 -c msgs.c -o build/temp.linux-i686-2.6/msgs.o > gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_FREETDS=1 -I/opt/sybase/SYBSsa9/include -I/usr/include/python2.6 -c numeric.c -o build/temp.linux-i686-2.6/numeric.o > gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_FREETDS=1 -I/opt/sybase/SYBSsa9/include -I/usr/include/python2.6 -c money.c -o build/temp.linux-i686-2.6/money.o > gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_FREETDS=1 -I/opt/sybase/SYBSsa9/include -I/usr/include/python2.6 -c datetime.c -o build/temp.linux-i686-2.6/datetime.o > gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_FREETDS=1 -I/opt/sybase/SYBSsa9/include -I/usr/include/python2.6 -c date.c -o build/temp.linux-i686-2.6/date.o > gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWANT_BULKCOPY -DHAVE_DATETIME -DHAVE_DECIMAL -DHAVE_FREETDS=1 -I/opt/sybase/SYBSsa9/include -I/usr/include/python2.6 -c sybasect.c -o build/temp.linux-i686-2.6/sybasect.o > creating build/lib.linux-i686-2.6 > gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions build/temp.linux-i686-2.6/blk.o build/temp.linux-i686-2.6/databuf.o build/temp.linux-i686-2.6/cmd.o build/temp.linux-i686-2.6/conn.o build/temp.linux-i686-2.6/ctx.o build/temp.linux-i686-2.6/datafmt.o build/temp.linux-i686-2.6/iodesc.o build/temp.linux-i686-2.6/locale.o build/temp.linux-i686-2.6/msgs.o build/temp.linux-i686-2.6/numeric.o build/temp.linux-i686-2.6/money.o build/temp.linux-i686-2.6/datetime.o build/temp.linux-i686-2.6/date.o build/temp.linux-i686-2.6/sybasect.o -L/opt/sybase/SYBSsa9/lib -o build/lib.linux-i686-2.6/sybasect.so Or maybe it's Debian's fault for mixing stuff up into /usr/lib/pyshared etc.? -- Michał Sawicz <mi...@sa...> |
From: Andrew L. <and...@gm...> - 2011-02-04 10:15:20
|
I have the same problems with Debian lenny too. I can connect to DB with external console (sqsh in my variant) as you are. With FreeTDS debug feature I found that sqsh use CT-library for connections but python-mssql use DB-library. Probably, there is some way to make python-mssql to use CT-library? I don't know yet. With python-sybase I have the same problems, except that I can make it with -D HAVE_FREETDS, receiving no errors. But "undefined symbol: cs_config" is still there. Did you solve you problem already? |
From: Michał S. <mi...@sa...> - 2011-02-04 10:35:51
|
Dnia 2011-02-04, pią o godzinie 10:09 +0000, Andrew Lazarev pisze: > Did you solve you problem already? I did work around that particular problem but have another issue, you can read my followup here: http://sourceforge.net/mailarchive/message.php?msg_id=26997237 Cheers, -- Michał Sawicz <mi...@sa...> |