pydantic-core icon indicating copy to clipboard operation
pydantic-core copied to clipboard

MySQLDsn build failed if password contains special character

Open zh0uquan opened this issue 1 year ago • 1 comments

Hello, running the following code to build mysql url will cause a error when password contains a special character #.

from pydantic import MySQLDsn
MySQLDsn.build(
      scheme="mysql+aiomysql",
      username="test", 
      password="test#1", 
      host="127.0.0.1", 
      port=3306, 
     path="test"
)

this is the error message

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pydantic_core._pydantic_core.ValidationError: 1 validation error for url
  Input should be a valid URL, invalid port number [type=url_parsing, input_value='mysql+aiomysql://test:test#[email protected]:3306/test', input_type=str]

zh0uquan avatar Sep 24 '24 05:09 zh0uquan