connector-x
connector-x copied to clipboard
# hashtag character causing error on authentication
What language are you using?
Python
What version are you using?
0.3.1
What database are you using?
MySQL
What dataframe are you using?
Pandas,
Can you describe your bug?
I have a database with "#" character in their credentials. I can't connect to it because of the hashtag, tried with another user and it works.
What are the steps to reproduce the behavior?
Connect to a MySQL database with a user having a "#" credential in it
cx.read_sql("mysql://user:aa###aaa@address:3306/db", str(query)).iloc[:, 0].tolist()
What is the error?
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/ubuntu/.cache/pypoetry/virtualenvs/api-ObXpZerD-py3.9/lib/python3.9/site-packages/connectorx/__init__.py", line 224, in read_sql
result = _read_sql(
RuntimeError: parse error: invalid port number
Can you try to urlencode your password first (as well as other parts like server address and user name if they also include special characters) and see whether it works? Here is a reference: https://github.com/sfu-db/connector-x/discussions/319#discussioncomment-3272921
Hi @wangxiaoying , I believe I'm having a similar issue (using connectorx python 0.3.2a5 and python 3.11.2).
I try to run cx.read_sql with a connection string containing a special character (in the password). If I url encode the password (with urllib.parse.quote_plus), I get RuntimeError: parse error: relative URL without a base. The server address doesn't have any special characters, and doesn't change when running it through urllib.parse.quote_plus; same with any other parts of the connection string.
Notably, the same exact connection string works to create a SQLAlchemy engine and execute a query.
Any ideas what I might be able to do to further troubleshoot? I appreciate any advice.
@parthlakhaniElligo same issue have you figured it out?
@avnav0 I had abandoned this project for a while because I couldn't find a working solution. I recently returned to it and this appears to have been resolved in the final version of 0.3.2 (released on the day of your comment, I believe); the same connection string I tried before now works without error (still need to url encode the special-character-containing components, of course). Hope you've also had better luck!
In the latest version of polars this still throws this error, but wangxiaoying's solution still works great