how to registry.register clickhouse-sqlalchemy to normally use it
now i meet one problem after packaging project code with pyinstaller. uri = f"clickhouse://{user}:{password}@{host}:{port}/{database}" engine = create_engine(uri, echo=False, poolclass=NullPool) -------with this code raise error: Please check the system service:Can't load plugin: sqlalchemy.dialects:clickhouse. seems need to registry.register first then to create_engine, but don't know how to write it:( registry.register('clickhouse', 'clickhouse_sqlalchemy', 'dialect')---raise error: error:module 'clickhouse_sqlalchemy' has no attribute 'dialect' how to write? thanks in advance!!!
Dialects registration takes place in setup.py: https://github.com/xzkostyan/clickhouse-sqlalchemy/blob/master/setup.py#L94. It seems something wrong with your installation.
yes, there is some issue with installation, now need to debug it. we use pyinstaller to pack codebase, using mange.spec as package configuration. add clickhouse_sqlalchemy into hiddenimports list in manage.spec, if not, will raise error no module named "clickhouse_sqlalchemy" found after packaging and using. maybe some thing wrong with hiddenimports
find some clue with https://snowflakecommunity.force.com/s/question/0D50Z00009Huss0SAB/how-to-get-pyinstaller-to-pack-snowflake-sqlalchemy-dialect, maybe change hook-sqlalchemy.py of pyinstaller with this line hiddenimports = ['pysqlite2', 'MySQLdb', 'psycopg2', 'sqlalchemy.ext.baked'] change to hiddenimports = ['pysqlite2', 'MySQLdb', 'psycopg2', 'sqlalchemy.ext.baked', 'clickhouse-sqlalchemy'] how do you guys think?
find solution from source code:) the link showed as below: https://github.com/xzkostyan/clickhouse-sqlalchemy/blob/master/tests/config.py register method as below when packaging with pyinstaller from sqlalchemy.dialects import registry registry.register( "clickhouse", "clickhouse_sqlalchemy.drivers.http.base", "dialect" )