Search code examples
pythonpython-3.xsybasesap-iq

Client side to connect to sybase IQ using Python3


I am using Ubuntu and I want to connect to a sybase IQ server (remote) from my client machine ,I tried installing/using sqlanydb according to sybase documentation, but i don't see any parameter in sqlanydb.connect() related to IP of the sybase server. I think this routine imagines that sybase db is on localhost, am I right?

  • Do i need to install the sybase on client side as well to be able to connect to that remote sybase db? or just the sqlanydb is enough?

  • How can I make this driver to connect to a remote server?


Solution

  • You do need to install the client software. The python driver is basically a python interface to the dbcapi client library, so you can't use it without the client software installed on the machine.

    For connecting to a remote server, you can use the HOST parameter. The connect() function takes as arguments any valid connection parameter, so a connection string like uid=steve;pwd=secretpassword;host=myserverhost:4567;dbn=mydatabase would translate to:

    sqlanydb.connect( uid = 'steve',
                      pwd = 'secretpassword',
                      host = 'myserverhost:4567',
                      dbn = 'mydatabase' )
    

    Connection parameters are documented here. If HOST is not used, the client attempts a shared memory connection. Shared memory is faster than TCP but obviously only works if the client and server are on the same machine.