cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Python ASE & IQ drivers

pythondev
Explorer
0 Likes
2,560

Hello,

I would like to execute queries in Python 2 (and 3 if possible) to ASE and IQ Sybase servers.

What are the most performant implementations in Python 2/3 ?

Best regards,

View Entire Topic
pythondev
Explorer
0 Likes

Hello joe.woodhouse, where can I download CPython driver to execute queries ? I've read https://help.sap.com/doc/4c40a79c93f4485ca2a01c5ba806c2f5/16.0.3.6/en-US/Adaptive_Server_Enterprise_... but it seems only Python 2 (released in 2012) is available on SourceForge.

I'm looking for a driver that will run on Python 3, GNU/Linux, Windows, IQ and ASE. Does that driver exist ? 🙂

ryan_hansen
Product and Topic Expert
Product and Topic Expert

Hi Richard,

Here is the setup using the SAP driver.

SDK 16.0 SP03 PL07:
$ source $SYBASE/SYBASE.csh
$ setenv PYTHONPATH $SYBASE/$SYBASE_OCS/python/python37_64r/lib
$ setenv PATH /pse/hansenr/python37/bin:$PATH

$ cat firstapp.py
import sybpydb
conn = sybpydb.connect(user='DBA', password='sql')
cur = conn.cursor()
cur.execute("select * from mytable")
while True:
row = cur.fetchone()
if (not row):
break
print("%s: %s" % (row[0], row[1]))
cur.close()
conn.close()

$ cat $SYBASE/interfaces
ASE
query tcp ether ASEHOST ASEPORT
IQ
query tcp ether IQHOST IQPORT

isql -UDBA -Psql -SIQ
1>create table mytable (c1 int, c2 varchar(50))
2>go
1> insert into mytable values (1, "test")
2> go
(1 row affected)

isql -Usa -Ppassword -SASE
1> create table mytable (c1 int, c2 varchar(50))
2> go
1> insert into mytable values (2, "test2")
2> go
(1 row affected)

$ setenv DSQUERY ASE
$ python3 firstapp.py
2: test2

$ setenv DSQUERY IQ
Modify username and password
$ python3 firstapp.py
1: test


Hope this helps,

Ryan