2

I installed SQL Anywhere 17 client. I ran /opt/sqlanywhere17/bin64/sa_config.sh And still have problem with sqlanydb.InterfaceError: ('Could not load dbcapi. Tried:None,dbcapi.dll,libdbcapi_r.so,libdbcapi_r.dylib', 0)

#!/usr/bin/python3.6
# -*- coding: utf-8 -*-
import ctypes
import sqlanydb
conn = sqlanydb.connect(UserID='XXX', Password='XXX', Host='10.10.10.10', DatabaseName='XXX', ServerName='XXX')
curs = conn.cursor()
curs.close()
conn.close()

Log:

Traceback (most recent call last):
  File "./systest.py", line 6, in <module>
    conn = sqlanydb.connect(UserID='XXX', Password='XXX', Host='10.10.10.10', DatabaseName='XXX', ServerName='XXX')
  File "/usr/local/lib/python3.6/site-packages/sqlanydb.py", line 522, in connect
    return Connection(args, kwargs)
  File "/usr/local/lib/python3.6/site-packages/sqlanydb.py", line 538, in __init__
    parent = Connection.cls_parent = Root("PYTHON")
  File "/usr/local/lib/python3.6/site-packages/sqlanydb.py", line 464, in __init__
    'libdbcapi_r.dylib')
  File "/usr/local/lib/python3.6/site-packages/sqlanydb.py", line 456, in load_library
    raise InterfaceError("Could not load dbcapi.  Tried: " + ','.join(map(str, names)))
sqlanydb.InterfaceError: ('Could not load dbcapi.  Tried: None,dbcapi.dll,libdbcapi_r.so,libdbcapi_r.dylib', 0)

Thanks for your help in advance

  • Can you find any of the `ibdbcapi_r.so` or `libdbcapi_r.dylib` mentioned? If the library is not in a standard location, can you append its directory to `LD_LIBRARY_PATH` before running the script? – 9000 Nov 18 '19 at 19:45
  • I added line os.environ["LD_LIBRARY_PATH"] = "/opt/sqlanywhere17/lib64/libdbcapi_r.so" to script and still have problem. I don't know that I understand you because I'm beginner with python. –  Nov 18 '19 at 20:16
  • It won't run like that; you python process needs this to be set before it starts. A command line like `LD_LIBRARY_PATH=... python your_script.py` could work. – 9000 Nov 18 '19 at 21:02
  • It doesn't helped. Still this same error. –  Nov 19 '19 at 14:09

1 Answers1

0

I faced the same issue and took me 2 days to solve it.

Here is the solution, your solution is in point 2.

  1. If running on Linux or one of the Unix platforms, you'll need to set up your environment before launching Python. So, download the sql anywhere12 / 17 and install. ( You have done this)

  2. open the terminal and run sa_config{.sh|.csh} script so your Python application can locate the required libraries (including libdbcapi12.dll). Make sure that you run sa_config.sh file and app.py in same terminal otherwise you will face the same issue.

Example, I have created the bash file which run first.

. /opt/sqlanywhere17/bin32/sa_config.sh
python app.py

source : Full answer can be found here on sqlanywhere forum

Ujesh Nada
  • 165
  • 1
  • 9