Subject Re: [firebird-python] fdb - accented characters
Author Werner
On 7/9/2014 17:03, Werner wernerfbd@... [firebird-python] wrote:
 

Hi,

On 7/9/2014 16:23, Werner wernerfbd@... [firebird-python] wrote:
 

Hi,

Me again, running into problems if my data contains accented characters, e.g. 'é'.

This is still with Py3.4 and SQLAlchemy 0.9.6.

sqlalchemy.exc.DatabaseError: (DatabaseError) ('Error while executing SQL statement:\n- SQLCODE: -303\n- Dynamic SQL Error\n- SQL error code = -303\n- Malformed string', -303, 335544569) 'INSERT INTO language (id, name, code2, code5, created_at, updated_at, created_by, updated_by) VALUES (?, ?, ?, ?, ?, ?, ?, ?)' ((1, 'English', 'en', 'en_EN', datetime.datetime(2014, 7, 9, 16, 4, 9, 2963), None, None, None), (2, 'Français', 'fr', 'fr_FR', datetime.datetime(2014, 7, 9, 16, 4, 9, 2963), None, None, None), (3, 'Deutsch', 'de', 'de_DE', datetime.datetime(2014, 7, 9, 16, 4, 9, 2963), None, None, None), (4, 'English - user defined', 'en', 'en_EN', datetime.datetime(2014, 7, 9, 16, 4, 9, 2963), None, None, None), (6, 'Dansk - support only in English', 'da', 'da_DA', datetime.datetime(2014, 7, 9, 16, 4, 9, 2963), None, None, None), (7, 'Néerlandais - support only in English', 'nl', 'nl_NL', datetime.datetime(2014, 7, 9, 16, 4, 9, 2963), None, None, None))

The problem is the 'ç' in Français and the 'é' in Néerlandais.

This worked for me in Py2.7 using kinterbasdb, so I wonder where I need to search, is it an fbd issue or SA or my source file encoding?

The source file encoding is "# -*- coding: utf-8 -*-" and the SA engine is setup "engine2 = db2.sa.create_engine(dburl, encoding='utf8', echo=False)".

I suspect the problem being line 2772 in fdb.fbcore:
value = value.encode(self.__python_charset)

self.__python_charset is in my case cp1252, shouldn't that use the connection charset?

Or I am not setting up the connection correctly for fdb?
Could it be to do with my use of type_conv=300 with kinterbasdb?

If yes, what can I do to get the same/similar behaviour with fdb?

Werner