<h3 dir="auto">Describe the bug</h3>
<p dir="auto">When connecting to the database, we use a connection string. What happens is when using an at ("@") inside the password, the db_engine object gets wrong password and host. This worked on the sqlalchemy version 1.4.9</p>
<p dir="auto">Going into debug-mode and looking at the db_engine object below, I can see that the password has been split on the first at sign ("@"). What should actually happen is not splitting the password, but splitting on the last at sign in the string before the connection string.</p>
<p dir="auto">TLDR:</p>
<ul dir="auto">
<li>First part of password with @ is used as password.</li>
<li>Second part of password after @ is then part of the host string.</li>
</ul>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/6339551/130208354-246d6829-fc15-4bac-b5b8-0e3d06886c56.png"><img src="https://user-images.githubusercontent.com/6339551/130208354-246d6829-fc15-4bac-b5b8-0e3d06886c56.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/bjornamr/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/bjornamr">@bjornamr</a> and  <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/Falkon353/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/Falkon353">@Falkon353</a></p>
<h3 dir="auto">To Reproduce</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from sqlalchemy.orm import sessionmaker
from sqlalchemy import create_engine, Column, String
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

CONNECTION_STRING = &quot;mssql+pymssql://username:firstpartpass@lastpartpass@localhost:1433/dev&quot;

class User(Base):
    __tablename__ = &quot;user&quot;

    ssid = Column(String(256), primary_key=True, index=True)
    Name = Column(String(256))


db_engine = create_engine(CONNECTION_STRING)
db_session = sessionmaker(bind=db_engine)
Base.metadata.create_all(bind=db_engine)"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">sqlalchemy</span>.<span class="pl-s1">orm</span> <span class="pl-k">import</span> <span class="pl-s1">sessionmaker</span>
<span class="pl-k">from</span> <span class="pl-s1">sqlalchemy</span> <span class="pl-k">import</span> <span class="pl-s1">create_engine</span>, <span class="pl-v">Column</span>, <span class="pl-v">String</span>
<span class="pl-k">from</span> <span class="pl-s1">sqlalchemy</span>.<span class="pl-s1">ext</span>.<span class="pl-s1">declarative</span> <span class="pl-k">import</span> <span class="pl-s1">declarative_base</span>

<span class="pl-v">Base</span> <span class="pl-c1">=</span> <span class="pl-en">declarative_base</span>()

<span class="pl-v">CONNECTION_STRING</span> <span class="pl-c1">=</span> <span class="pl-s">"mssql+pymssql://username:firstpartpass@lastpartpass@localhost:1433/dev"</span>

<span class="pl-k">class</span> <span class="pl-v">User</span>(<span class="pl-v">Base</span>):
    <span class="pl-s1">__tablename__</span> <span class="pl-c1">=</span> <span class="pl-s">"user"</span>

    <span class="pl-s1">ssid</span> <span class="pl-c1">=</span> <span class="pl-v">Column</span>(<span class="pl-v">String</span>(<span class="pl-c1">256</span>), <span class="pl-s1">primary_key</span><span class="pl-c1">=</span><span class="pl-c1">True</span>, <span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-c1">True</span>)
    <span class="pl-v">Name</span> <span class="pl-c1">=</span> <span class="pl-v">Column</span>(<span class="pl-v">String</span>(<span class="pl-c1">256</span>))


<span class="pl-s1">db_engine</span> <span class="pl-c1">=</span> <span class="pl-en">create_engine</span>(<span class="pl-v">CONNECTION_STRING</span>)
<span class="pl-s1">db_session</span> <span class="pl-c1">=</span> <span class="pl-en">sessionmaker</span>(<span class="pl-s1">bind</span><span class="pl-c1">=</span><span class="pl-s1">db_engine</span>)
<span class="pl-v">Base</span>.<span class="pl-s1">metadata</span>.<span class="pl-en">create_all</span>(<span class="pl-s1">bind</span><span class="pl-c1">=</span><span class="pl-s1">db_engine</span>)</pre></div>
<h3 dir="auto">Error</h3>
<p dir="auto">Exception has occurred: OperationalError<br>
(pymssql._pymssql.OperationalError) (20009, b'DB-Lib error message 20009, severity 9:\nUnable to connect: Adaptive Server is unavailable or does not exist (<a href="mailto:YARge@CHN-CL-DEVSQL.MCHP-MAIN.COM">YARge@CHN-CL-DEVSQL.MCHP-MAIN.COM</a>)\n')<br>
(Background on this error at: <a href="https://sqlalche.me/e/14/e3q8" rel="nofollow">https://sqlalche.me/e/14/e3q8</a>)</p>
<p dir="auto">During handling of the above exception, another exception occurred:</p>
<p dir="auto">The above exception was the direct cause of the following exception:</p>
<p dir="auto">File "password_error.py", line 19, in <br>
Base.metadata.create_all(bind=db_engine)</p>
<h3 dir="auto">Versions</h3>
<ul dir="auto">
<li>OS: Windows 10</li>
<li>Python: 3.8</li>
<li>SQLAlchemy: 1.4.22</li>
<li>Database: MS SQL 2019</li>
<li>DBAPI: pymssql version: 2.2.1</li>
</ul>
<h3 dir="auto">Additional context</h3>
<p dir="auto"><em>No response</em></p>
<p dir="auto"><strong>Describe the bug</strong><br>
When a password contains a <code class="notranslate">@</code> character.  Sqlalchemy with a string url cannot connect to the database.</p>
<p dir="auto">I greatly suspect that it was induced by <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="891509156" data-permission-text="Title is private" data-url="https://github.com/sqlalchemy/sqlalchemy/issues/6482" data-hovercard-type="issue" data-hovercard-url="/sqlalchemy/sqlalchemy/issues/6482/hovercard" href="https://github.com/sqlalchemy/sqlalchemy/issues/6482">#6482</a>.</p>
<p dir="auto">Was working fine in 1.4.15.</p>
<p dir="auto"><strong>To Reproduce</strong></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    url = (
        &quot;mssql+pyodbc://&quot;
        &quot;SA:P@my_password@127.0.0.1:1433/master&quot;
        &quot;?driver=ODBC Driver 17 for SQL Server&quot;
    )"><pre class="notranslate">    <span class="pl-s1">url</span> <span class="pl-c1">=</span> (
        <span class="pl-s">"mssql+pyodbc://"</span>
        <span class="pl-s">"SA:P@my_password@127.0.0.1:1433/master"</span>
        <span class="pl-s">"?driver=ODBC Driver 17 for SQL Server"</span>
    )</pre></div>
<p dir="auto"><strong>Error</strong><br>
``<br>
sqlalchemy.exc.OperationalError: (pyodbc.OperationalError) ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')</p>
<p dir="auto">``</p>
<p dir="auto"><strong>Versions.</strong></p>
<ul dir="auto">
<li>OS:</li>
<li>Python: 3.8</li>
<li>SQLAlchemy: 1.4.17</li>
<li>Database: mssql</li>
<li>DBAPI: pyodbc</li>
</ul>
<p dir="auto"><strong>Have a nice day!</strong></p>