SAP / sqlalchemy-hana

SQLAlchemy Dialect for SAP HANA
Apache License 2.0
128 stars 56 forks source link

Problem fetching NCLOB column #100

Closed paoloalba closed 1 year ago

paoloalba commented 1 year ago

I connect to an SAP HANA Cloud database through hdbcli drivers, and I get the following stack trace:

Error: (-10419, ' Character value contains non-ASCII characters (8)')

The specific error arises from the call of the dbapi_cursor.fetchall().

After investigation, I found that the removal of the single column present in the query of type NCLOB makes the query successfull. Indeed there are non-ASCII chars present in the column, but to my understanding the data type NCLOB should be able to have utf8 content. I tried to set the parameter charset in the connection string, in the case there was any other charset defined by default, but I had no success in here. The connection string uses hana+hdbcli; other queries with several data types, including NVARCHAR, work properly.

paoloalba commented 1 year ago

Despite having overridden the column type within the model, the driver was fetching the data as per table scheme from the server, where the column type was CLOB. The only solution was in the end to modify the column type to NCLOB explicitly.