zopefoundation / Products.SQLAlchemyDA

SQLAlchemyDA is a generic database adapter for ZSQL methods. Since it is based on SQLAlchemy, SQLAlchemyDA supports all databases out-of-the box that are supported by SQLAlchemy (Postgres, MySQL, Oracle, SQLite, MS-SQL, Firebird, Informix).
Other
2 stars 10 forks source link

client_encoding #11

Closed LutzSteinborn closed 3 years ago

LutzSteinborn commented 3 years ago

Hello,

I have a old postgres DB with SQL_ASCII as encoding. In this DB strings are cp1252 encoded. Then I'm using sqlalchemy direct I'm working with engine = create_engine(config.DATABASE_URI, echo=config.ECHO, client_encoding='win1252') and it works fine. How can I use client_encoding with SQLAlchemyDA?

Regards Lutz

dataflake commented 3 years ago

The database connector object has a method add_extra_engine_options to pass additional options for the call to create_engine, but this is only available from Python code. There's no setting in the Zope ZMI that calls this method.

https://github.com/zopefoundation/Products.SQLAlchemyDA/blob/5eeb1375c404a73b6affe414e8639850596593ce/src/Products/SQLAlchemyDA/da.py#L301-L310

LutzSteinborn commented 3 years ago

Made my day. Thanks for the very useful hint. The client_encoding is now hardcoded in our installed version of SQLAlchemyDA/da.py. I'm interested to add this as an extra option to ZMI. Can you give advise how to do this?

Other question: how to bring a old Zope 2.7.7 Data.fs made with Python 2.4.6 to Zope4 with Python 2.7? I've tried with exporti/import and using Data.fs directly. Nothing work. At the moment we are planing to port it bz creating all objects by hand copy/pasting the content.

jugmac00 commented 3 years ago

Other question: how to bring a old Zope 2.7.7 Data.fs made with Python 2.4.6 to Zope4 with Python 2.7? I've tried with exporti/import and using Data.fs directly. Nothing work. At the moment we are planing to port it bz creating all objects by hand copy/pasting the content.

About your second question. This is completely off-topic here. Please direct general questions to the community forum: https://community.plone.org/

dataflake commented 3 years ago

For ZODB migrations take a look at the official documentation at https://zope.readthedocs.io/en/latest/migrations/index.html