Digital-Sapphire/PyUpdater

How to properly include SQLAlchemy dialect in a build?

chucklay opened this issue · 2 comments

Hi there, I'm working on a project that involves the use of SQLAlchemy, and the sqlalchemy-hana dialect/driver. I've been able to use spec files to deal with some hidden imports in the past, but I'm at a loss as to how to get sqlalchemy to cooperate. Pyinstaller has a default hook for sqlalchemy (https://github.com/pyinstaller/pyinstaller/blob/develop/PyInstaller/hooks/hook-sqlalchemy.py) but I don't see one for pyupdater.

I've tried copying the hook from pyinstaller (and adding sqlalchemy_hana and/or sqlalchemy.dialects.hana to the hidden_imports) but still no dice. I'm pretty lost, even after reading the documentation and could definitely use a hand. Thanks!

hi @chucklay
As PyUpdater uses PyInstaller, it should just work.
Can you tell me what version of PyUpdater and PyInstaller you're using. IN addition, if you're using PyInstaller => 4, can you tell me the version of pyinstaller-hooks-contrib you're using?

Hey there, sorry for the late response. I was actually able to get this working by manually registering the dialects in SQLAlchemy when our database interaction code loads. I'm not sure why it wasn't being picked up automatically, but I'm guessing it either had to do with how we get our engine (the code in question is designed to work with multiple different database systems) or some quirk of how the hana plugin loads.

Either way, adding this fixed it, and PyInstaller picked up the dialect:

from sqlalchemy.dialects import registry
registry.register('hana', 'sqlalchemy_hana.dialect', 'HANAHDBCLIDialect')
registry.register('hana.hdbcli', 'sqlalchemy_hana.dialect', 'HANAHDBCLIDialect')
registry.register('hana.pyhdb', 'sqlalchemy_hana.dialect', 'HANAPyHDBDialect'