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

Special characters in clickhouse password causes CSV dump to fail #168

Closed
moonlightelite opened this issue Jan 24, 2020 · 1 comment
Closed
Labels

Comments

@moonlightelite
Copy link

moonlightelite commented Jan 24, 2020

If one uses a clickhouse account password with special characters and tries to use pump-data + CSV, during the tail | clickhouse-client call (thru Bash), the password would be escaped by Bash and causes authentication failure.

2020-01-24 10:38:10,209/1579891090.209181:INFO:starting clickhouse-client process
2020-01-24 10:38:10,209/1579891090.209221:DEBUG:starting tail -n +2 'yyyyyyy_1579891090.202464_12a560ba-7819-4d01-a114-053757d98264.csv' | clickhouse-client --host=127.0.0.1 --port=9000 --user=default --password=xxxxxxxx --query='INSERT INTO ....... FORMAT CSV' Code: 193. DB::Exception: Received from 127.0.0.1:9000. DB::Exception: Wrong password for user default.

tail: write error: Broken pipe
2020-01-24 10:38:10,230/1579891090.230426:DEBUG:class:<class 'clickhouse_mysql.writer.processwriter.ProcessWriter'> process() done
2020-01-24 10:38:11,225/1579891091.225788:DEBUG:Check events in binlog stream

A propose fix would be to single quote the password during argument construction (

choptions += " --password=" + self.password
)

            if self.password:
                choptions += " --password='" + self.password + "'"
            bash = "tail -n +2 '{0}' | clickhouse-client {1} --query='{2}'".format(
                event.filename,
                choptions,
                sql,
            )

Thanks

@sunsingerus
Copy link
Collaborator

The more generic way is to use quote/escape values in bash commands
Please check

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

No branches or pull requests

2 participants