sqlanywhere / sqlanydb

Python driver for SAP Sybase SQL Anywhere
Other
43 stars 20 forks source link

Latest macOS(?) driver is incompatible #24

Closed hynek closed 2 years ago

hynek commented 3 years ago

After updating to sqla17_client_macosx.17010_6178 from https://wiki.scn.sap.com/wiki/display/SQLANY/SAP+SQL+Anywhere+Database+Client+Download the driver stopped working. At least NULL interpolation handling is broken now.

Here's an SSCCE:

create table new_driver_test (col1 timestamp with time zone null);
In [1]: import  sqlanydb; conn = sqlanydb.connect(links="tcpip(host=localhost;DoBroadcast=None)", ServerName="XXX", uid="DBA", pwd=""); c = conn.cursor()
In [3]: c.execute("insert into new_driver_test values (?)", (None,))
---------------------------------------------------------------------------
OperationalError                          Traceback (most recent call last)
<ipython-input-3-954ca3385b83> in <module>
----> 1 c.execute("insert into new_driver_test values (?)", (None,))

~/Work/customer-api/.direnv/python-3.8.6/lib/python3.8/site-packages/sqlanydb.py in execute(self, operation, parameters)
    792
    793     def execute(self, operation, parameters = ()):
--> 794         self.executemany(operation, [parameters])
    795
    796     def callproc(self, procname, parameters = ()):

~/Work/customer-api/.direnv/python-3.8.6/lib/python3.8/site-packages/sqlanydb.py in executemany(self, operation, seq_of_parameters)
    769                          for k, col in enumerate(parameters[:bind_count])]
    770                 if not self.api.sqlany_execute(self.stmt):
--> 771                     self.handleerror(*self.parent.error())
    772
    773                 try:

~/Work/customer-api/.direnv/python-3.8.6/lib/python3.8/site-packages/sqlanydb.py in handleerror(self, errorclass, errorvalue, sqlcode)
    691         if errorclass:
    692             eh = self.errorhandler or standardErrorHandler
--> 693             eh(self.parent, self, errorclass, errorvalue, sqlcode)
    694
    695     def __stmt_get(self):

~/Work/customer-api/.direnv/python-3.8.6/lib/python3.8/site-packages/sqlanydb.py in standardErrorHandler(connection, cursor, errorclass, errorvalue, sqlcode)
    377             cursor.messages.append(error)
    378     if errorclass != Warning:
--> 379         raise errorclass(errorvalue,sqlcode)
    380
    381

OperationalError: (b'Cannot convert integer to timestamp with time zone', -157)

Without interpolation it works fine:

In [4]: c.execute("insert into new_driver_test values (NULL)")

In [5]: c.execute("insert into new_driver_test values (NULL)", ())

This is a big deal because it means we're stuck with old drivers potentially forever. Given that there hasn't been any activity since 2018, is there any chance this will be remediated? What are the options to paying customers? Who can we talk to for SAP to pick this up again?

DanCummins-SAP commented 3 years ago

Hi Hynek,

I'm on the team responsible for this driver at SAP. I've entered a bug report (260987) - someone on our team will look into it.

Kind regards, Dan

DanCummins-SAP commented 3 years ago

Hi Hynek, Sorry for the delay. I posted a new version on github and PyPi which should contain the fix. Kind regards, Dan

hynek commented 3 years ago

Thank you, I will try it out!

For the record, I have skimmed the commit and your except syntax is rather arcane. You've basically made your test suite Python 2-only. Correct syntax is except Exception as e: instead of a comma now.

hynek commented 3 years ago

@DanCummins-SAP since this is the only channel I know to reach anyone in power: sqlalchemy-sqlany is incompatible with SQLAlchemy 1.4 that has been released yesterday: https://github.com/sqlanywhere/sqlalchemy-sqlany/issues/13

hynek commented 2 years ago

Hi @DanCummins-SAP so I've tried it out much earlier, but the errors it's throwing now are even weirder and I've procrastinated on debugging it.

So here's the current state:

The currently downloadable macOS driver from https://wiki.scn.sap.com/wiki/display/SQLANY/SAP+SQL+Anywhere+Database+Client+Download is still sqla17_client_macosx.17010_6178.

It cannot be installed on macOS releases of the past two years. If I run client17010/Install SQL Anywhere.app/Contents/Resources/sqlany17/setup I'm getting

Warning: it appears that your system does not meet the minimum
system requirements to install this product.

For a list of operating system patches required to run
SQL Anywhere 17 please visit
http://scn.sap.com/docs/DOC-35654

on both Big Sur (11) and Monterey (12). I won't even dare to ask about ARM builds for macOS.


I still had an archived installation from before, so I using that one and I'm getting:

Attempting to load dbcapi library
Successfully loaded dbcapi library '<CDLL 'libdbcapi_r.dylib', handle 20d4e8360 at 0x10b736ad0>' with name 'libdbcapi_r.dylib'
Attempting to initalize dbcapi context (self.api.sqlany_init_ex) with arguments: app name: 'PYTHON', api version: '2'
Failed to initalize dbcapi context (self.api.sqlany_init_ex returned NULL),perhaps you are missing some required sqlanywhere libaries?

I also tried stepping thru the code with a debugger, but the log is correct, this line is failing https://github.com/sqlanywhere/sqlanydb/blob/952183ab0504d14b3e32f2f5afb674514492deee/sqlanydb.py#L473 by returning a NULL.

Since sqlany_init_ex is closed source C driver code, I'm at my wits end here and keep using the drivers from 2018, anxious about them breaking.

I know you're the wrong tree to bark at, but as a paying customer this is extremely frustrating.

hynek commented 2 years ago

I have managed to install the latest OS driver and with that it works again.

For those Googling, the trick is:

  1. unpack the client archive
  2. cd into Install SQL Anywhere.app/Contents/Resources/sqlany17
  3. export SQLANY_FORCE_INSTALL=1
  4. ./setup -nogui