Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error connecting with the database when password contains a special character (+%...) with native engine. #291

Open
marcvivancos opened this issue Feb 6, 2024 · 1 comment

Comments

@marcvivancos
Copy link

marcvivancos commented Feb 6, 2024

Describe the bug
The bug is when there is a special character in the password, the problem seems to be in the file drives/native/base.py where the password and the username get quote two times. First in the function create_connect_args and then in the render_as_string method from sqlalchemy url:

    def create_connect_args(self, url):
        url = url.set(drivername='clickhouse')
        if url.username:
            url = url.set(username=quote(url.username))

        if url.password:
            url = url.set(password=quote(url.password))

        self.engine_reflection = asbool(
            url.query.get('engine_reflection', 'true')
        )

        return (url.render_as_string(hide_password=False), ), {}

So a password 123+X becomes 123%252BX when it should be 123%2BX

To Reproduce

from sqlalchemy import text
from sqlalchemy.engine import create_engine


if __name__ == "__main__":
    url = "clickhouse+native://default:123+X@localhost:9000/default"
    engine = create_engine(url)
    with engine.connect() as conn:
        conn.execute(text("SELECT version();"))

Expected behavior
Correctly connect to the database with a password with a special character

Versions

  • Clickhouse SQLAlchemy: 0.3.0
  • Python: 3.10.6
@jfmlima
Copy link

jfmlima commented Mar 19, 2024

This 4a4931f commit fixes this right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants