2

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?

Ivan Kolesnikov
  • 1,787
  • 1
  • 29
  • 45
john.doo
  • 23
  • 1
  • 3

2 Answers2

4

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.

Graeme Perrow
  • 56,086
  • 21
  • 82
  • 121
  • thanks, yeah it worked, i also found another solution using `links=tcpip()...` I am interested to know its difference with your solution performance wise! – john.doo Mar 21 '17 at 18:21
  • The `links` parameter is older and is used when you don't know what machine the database server is running on. It sends out UDP broadcast packets, which the server responds to and then it makes a TCP connection from there. The `host` parameter was added later and specifies exactly where the server is running. When using `links`, the client caches the result so that the 2nd and subsequent times, it doesn't have to send out the broadcasts. There is no performance difference except the first time the client is connecting to a particular server. – Graeme Perrow Mar 21 '17 at 19:50
0

You can connect with below api,

import Sybase
db = Sybase.connect('server','name','pass','database')
c = db.cursor()
c.execute("sql statement")

Make sure dsn is present in sql.ini file.

Saurabh
  • 7,525
  • 4
  • 45
  • 46