Sqlalchemy shows “Code 516 Authentication failed” when trying to connect to clickhouse db

梦想与她 提交于 2020-05-30 03:37:29

问题


I have connected to a clickhouse db with dbeaver and installed sqlalchemy v1.3.13 and clickhouse-sqlalchemy 0.1.3 for python 3.7.

When I tried to connect with

from sqlalchemy import create_engine 
engine_clickhouse = create_engine('clickhouse://use:pass@host:port/db')
engine_clickhouse.raw_connection()

I got

Exception: Code: 516, e.displayText() = DB::Exception: default: Authentication failed: password is incorrect or there is no user with such name (version 20.3.4.10 (official build))

Does anybody know why? I didn't find a similar issue.


回答1:


This issue is well-known - look at sqlalchemy-clickhouse Issue-45 or sqlalchemy-clickhouse Issue-49.

To fix it need to explicitly downgrade the package infi.clickhouse_orm up to version 1.0.4:

requirements.txt

...
infi.clickhouse_orm==1.0.4

It allows using the _build_params-function with the behavior expected by sqlalchemy-clickhouse (following versions of infi.clickhouse_orm aren't passed the password that leads to 'Authentication failed..'-error).

Or alternatively can be used the fork where fixed this error, for example adaiboy fork.


I would avoid using the official sqlalchemy-clickhouse because:

  • fixes not committed to master ("Latest commit was on 23 Jan 2019" !!)
  • new featured not adding
  • there are some issues with pandas etc

clickhouse-driver is the greatest alternative for sqlalchemy-clickhouse.




回答2:


According to @vladimir reply.I tried

pip uninstall infi.clickhouse_orm
pip install infi.clickhouse_orm==1.0.4

It worked for me. Thanks



来源:https://stackoverflow.com/questions/61117610/sqlalchemy-shows-code-516-authentication-failed-when-trying-to-connect-to-clic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!