utf-8 coding problems using python pyodbc to connect to a Sybase Database in a Docker container

Discussion of open issues, suggestions and bugs regarding usage of ODBC Drivers
Post Reply

Stellar
Devart Team
Posts: 383
Joined: Tue 03 Oct 2017 11:00

Re: utf-8 coding problems using python pyodbc to connect to a Sybase Database in a Docker container

Post by Stellar » Tue 03 Mar 2020 12:54

Thank you for the information. Please describe the issue in more detail: in which case you get 'M\x8adic' instead of 'Mèdic'? Does the issue occur when retrieving metadata (table and column names) or when retrieving records from a table?

jordi588
Posts: 2
Joined: Fri 28 Feb 2020 14:35

Re: utf-8 coding problems using python pyodbc to connect to a Sybase Database in a Docker container

Post by jordi588 » Wed 04 Mar 2020 14:33

Hi Stellar, and thanks for the reply!

Well, first, it is not only on the 'M\x8adic' example, it occurs when appearing each single special character of the language I'm using on my application (Catalan). I get each single special character with a weird codification (another example: 'Quir\x97rgic' instead of 'Quirúrgic'). The issue occurs when retrieving records from a table.

What surprise my is that if I install the 'Devart ODBC Driver for ASE' in my local Windows the data is outputed correctly whereas the output data is strangely outputed in the Docker container of the application (which is a Debian distribution).

I tried everything possible on the pyodbc python module configuration without success which causes me the impression that I have to modify something in the Dockerfile related to the driver.

Probably the .so file configuration I get in the Docker container when the Driver is installed?

Thanks for your time!

Stellar
Devart Team
Posts: 383
Joined: Tue 03 Oct 2017 11:00

Re: utf-8 coding problems using python pyodbc to connect to a Sybase Database in a Docker container

Post by Stellar » Mon 16 Mar 2020 11:46

If UTF-8 encoding is set on both client and server side, there shouldn't be any issues with character encoding.
Please try adding the parameter "String Types" with the value "Unicode" to the connection string.

For example:
DRIVER=Devart ODBC Driver for ASE;String Types=Unicode;Data Source=Server_name;Database=test;User ID=sa;Password=pwd

Post Reply