Reputation: 7260
I'm afraid this might is just an configuration issue but maybe also some issue with coding. However, I'm trying to connect with a database using Python and sqlanydb. SQLAnywhere is installed within /opt/sybase and Shell is sourcing the sa_config.sh file.
Connection with normal tools are working well: E.g. via
dbisql -c "uid=dba;pwd=sql;eng=mydemo"
However, when I try doing this in Python with
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import ctypes
import sqlanydb
def main(args):
db1 = sqlanydb.connect( userid="DBA",
password="sql",
DataSourceName="mytest")
db1.close
return 0
if __name__ == '__main__':
import sys
sys.exit(main(sys.argv))
it's failing with
Traceback (most recent call last):
File "./myfile.py", line 52, in <module>
sys.exit(main(sys.argv))
File "./myfile.py", line 42, in main
DataSourceName="mytest")
File "/usr/local/lib/python2.7/dist-packages/sqlanydb.py", line 461, in connect
return Connection(args, kwargs)
File "/usr/local/lib/python2.7/dist-packages/sqlanydb.py", line 510, in __init__
self.handleerror(*error)
File "/usr/local/lib/python2.7/dist-packages/sqlanydb.py", line 520, in handleerror
eh(self, None, errorclass, errorvalue)
File "/usr/local/lib/python2.7/dist-packages/sqlanydb.py", line 342, in standardErrorHandler
raise errorclass(errorvalue)
sqlanydb.OperationalError: Parse error: Cannot find .ini file
I had a look onto sources of sqlanydb but didn't find any reference to an .ini file looking for at this point. So what is the correct way of enabling the ASA16 to run with sqlanydb?
Upvotes: 1
Views: 2693
Reputation: 57248
That's the error you'll get if you have no ~/.odbc.ini
file. You are specifying "DataSourceName=mytest", which tells the SQL Anywhere ODBC driver to look in ~/.odbc.ini
for a DSN called mytest, but no .ini file was found.
Use the dbdsn utility to create the DSN in question.
Full disclosure: I work for SAP in SQL Anywhere engineering.
Upvotes: 1