Closed
Description
Versions
- OS: CentOS 7
- Python: 3.6.8
- SQLAlchemy: 1.4.15
- Database: Mysql
- DBAPI: pymysql
When creating_engine, if the password contains special characters, I understand that it is URL Encoding
DB Test
IP : 1.1.1.1
PORT: 3306
ID: test
PW: test
DB Name: test@test
question
- What should I do if there are special characters in DB Name?
DB Name does not appear to be doing separate decoding
742 tokens = components["database"].split("?", 2)
743 components["database"] = tokens[0]
Parsing error on regular expression below when @ is entered in DB Name
re.compile('\n (?P[\w\+]+)://\n (?:\n (?P[^:/])\n (?::(?P.))?\n @)?\n (?:\n (?:\n , re.VERBOSE)
{'name': 'mysql+pymysql', 'username': 'test', 'password': 'test@1.1.1.1:3306/test', 'ipv6host': None, 'ipv4host': 'test', 'port': None, 'database': None}
Metadata
Metadata
Assignees
Labels
please escape non-alphanumeric characters in passwordsengines, connections, transactions, isolation levels, execution optionsmaybe a little more involved than "easy' but still doable for motivated newcomersnot really a feature or a bug; can be support for new DB features or user use cases not anticipated
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
zzzeek commentedon May 14, 2021
no solution right now other than programmatic construction of the URL object:
[-]What should I do if there is a special character in the DB name?[/-][+]add _rfc_1738_unquote to database portion of URL[/+][-]add _rfc_1738_unquote to database portion of URL[/-][+]accommodate for @ in database portion even if user:pass is present[/+]zzzeek commentedon May 24, 2021
we already support @ in the database portion, but it was only tested with a file-only URL.
sqla-tester commentedon May 24, 2021
Mike Bayer has proposed a fix for this issue in the master branch:
URL parsing fixes https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/2838
BuSHari commentedon May 31, 2021
That fix broke our engine connection when we use '@' in our password string, we wanted to avoid using urlib parse quote.
Anyway to revert that fix?
CaselIT commentedon May 31, 2021
I think the new behaviour is the correct one, since previously it would result in the wrong parsing of the url.
As documented, special characters in the password field should be quoted, so I would suggest quoting the password.
dwt commentedon May 31, 2021
Out of interest, how do I do that in a connection url like this? We configure our app via a config.ini file with
Right now the host is parsed as pass@staging.example.org - which of course doesn't work.
22 remaining items