I'm developing an html scraper and I want to write and rewrite the data obtained to a .db file using sqlanydb. I'm using Python3 and I've already downloaded SQL Anywhere 12. Importing sqlanydb library seems to work properly, but as soon as I implement the .connect(...) method the following error arises always, no matter on which path I specify the database:


File "example.py", line 30, in

databasefile="/blabla/data.db",

File "/usr/local/lib/python3.5/site-packages/sqlanydb.py", line 512, in connect

return Connection(args, kwargs)

File "/usr/local/lib/python3.5/site-packages/sqlanydb.py", line 528, in init

parent = Connection.cls_parent = Root("PYTHON")

File "/usr/local/lib/python3.5/site-packages/sqlanydb.py", line 454, in init

'libdbcapi_r.dylib')

File "/usr/local/lib/python3.5/site-packages/sqlanydb.py", line 446, in load_library

raise InterfaceError("Could not load dbcapi.  Tried: " + ','.join(names))

TypeError: sequence item 0: expected str instance, NoneType found


Could please anyone help me out with this?

Thank you.

asked 16 Feb '16, 06:22

pere93's gravatar image

pere93
46115
accept rate: 0%

edited 16 Feb '16, 10:39

Volker%20Barth's gravatar image

Volker Barth
40.1k361549819

Knowing which platform you are running this on will help. Also knowing what exactly you downloaded (and installed) may be important too.

If running on Linux or one of the Unix platforms, you'll need to set up your environment before launching Python. On those platforms you will need to source the sa_config{.sh|.csh} script so your Python application can locate the required libraries (including libdbcapi12.dll).

(16 Feb '16, 08:59) Nick Elson S...
Replies hidden

Of course, sorry. I'm running on a Mac OS X. I installed python3 along with the sqlanydb library, and downloaded SQL Anywhere 12.

I read somewhere about to run the sa_config.sh script by running ./Applications/SQLAnywhere12/System/bin32/sa_config.sh, or, anternatively, add SQLAnywhere/System/lib32 to the DYLD_LIBRARY_PATH which make the environment able to locate the libraries. I tried both but it still doesn't work, or perhaps I did it incorrectly....

What do you mean by setting up my environment before launching Python? Do you mean running the sa_config script before running my py file? I'm a bit lost so I will really appreciate a tutorial or at least a key guideline which could help me out fixing this.

Thank you.

(16 Feb '16, 10:22) pere93

I don't use Mac OS X, so I can't tell. But hopefully the following FAQ (or another one of those tagged with "macosx") is of help:

[http://sqlanywhere-forum.sap.com/questions/23704/python3-cannot-import-sqlanydb]

(16 Feb '16, 10:41) Volker Barth

Volker is correct. Graeme's answer was the final answer but it was a little hard to find (without showing all responses) ... so I promoted it to an answer.

The gist of this is that various BDS/Unix/Linux/OSX shells have their own way to "source" (yes, the word 'source' is a verb and a command in Unix/Posix/BSD shells) so that cmd has to be supplied as a separate token.

For Bash and Bourne sh the source cmd is a single '.' so one must type the 'dot' followed by a space and then your path ('./' for example) and then the file to execute as in:

`. ./sa_config.sh`

and for some other shells related to the 'C'-shell (csh) the source cmd is the word source as in

`source ./sa_config.csh`

I beleive the default for Mac OSX is the Bash shell so I would start by trying the first example; with a space.

permanent link

answered 16 Feb '16, 15:36

Nick%20Elson%20SAP%20SQL%20Anywhere's gravatar image

Nick Elson S...
7.3k35107
accept rate: 32%

edited 17 Feb '16, 11:51

1

Okay guys, I solved it. The problem finally was that the sa_config.csh script was left to execute. Once you execute both {.sh.csh} scripts, your environment is settled up properly and thus able to find every library on the SQLAnywhere platform.

Thank you Nick and Volker for your answers!

(17 Feb '16, 06:49) pere93
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×95
×31
×21
×11

question asked: 16 Feb '16, 06:22

question was seen: 5,328 times

last updated: 17 Feb '16, 11:51