<h3 dir="auto">Describe the bug</h3>
<p dir="auto">Traceback (most recent call last):<br>
File "", line 1, in <br>
File "/.../lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 3249, in connect<br>
return self._connection_cls(self)<br>
File "/.../lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 145, in <strong>init</strong><br>
self._dbapi_connection = engine.raw_connection()<br>
File "/.../lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 3273, in raw_connection<br>
return self.pool.connect()<br>
File "/.../lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 452, in connect<br>
return _ConnectionFairy._checkout(self)<br>
File "/.../lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 1253, in _checkout<br>
fairy = _ConnectionRecord.checkout(pool)<br>
File "/.../lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 715, in checkout<br>
rec = pool._do_get()<br>
File "/.../lib/python3.8/site-packages/sqlalchemy/pool/impl.py", line 169, in _do_get<br>
self._dec_overflow()<br>
File "/.../lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py", line 148, in <strong>exit</strong><br>
raise exc_value.with_traceback(exc_tb)<br>
File "/.../lib/python3.8/site-packages/sqlalchemy/pool/impl.py", line 166, in _do_get<br>
return self._create_connection()<br>
File "/.../lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 393, in _create_connection<br>
return _ConnectionRecord(self)<br>
File "/.../lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 678, in <strong>init</strong><br>
self.__connect()<br>
File "/.../lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 913, in __connect<br>
pool.dispatch.connect.for_modify(<br>
File "/.../lib/python3.8/site-packages/sqlalchemy/event/attr.py", line 473, in _exec_w_sync_on_first_run<br>
self(*args, **kw)<br>
File "/.../lib/python3.8/site-packages/sqlalchemy/event/attr.py", line 487, in <strong>call</strong><br>
fn(*args, **kw)<br>
File "/.../lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py", line 1881, in go<br>
return once_fn(*arg, **kw)<br>
File "/.../lib/python3.8/site-packages/sqlalchemy/engine/create.py", line 746, in first_connect<br>
dialect.initialize(c)<br>
File "/.../lib/python3.8/site-packages/sqlalchemy/dialects/postgresql/psycopg.py", line 356, in initialize<br>
info = self._type_info_fetch(connection, "hstore")<br>
File "/.../lib/python3.8/site-packages/sqlalchemy/dialects/postgresql/psycopg.py", line 342, in _type_info_fetch<br>
return TypeInfo.fetch(connection.connection, name)<br>
File "/.../lib/python3.8/site-packages/psycopg/_typeinfo.py", line 86, in fetch<br>
raise TypeError(<br>
TypeError: expected Connection or AsyncConnection, got _AdhocProxiedConnection</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="create some new project dir and in dir 

$ pipenv install &quot;psycopg[binary]&quot;
$ pipenv install --pre SQLAlchemy

$ docker run --rm --name some-postgres -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword postgres

another shell
$ docker exec -it some-postgres bash

$ psql -U postgres

CREATE DATABASE &quot;app-store&quot;;
CREATE USER &quot;app-user&quot; WITH ENCRYPTED PASSWORD 'app-password';
GRANT ALL PRIVILEGES ON DATABASE &quot;app-store&quot; TO &quot;app-user&quot;;

again in project dir shell

$ pipenv shell
$ python
$ python
Python 3.8.10 (default, Nov 14 2022, 12:59:47) 
[GCC 9.4.0] on linux
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; from sqlalchemy import create_engine
my import text

engine = create_engine(&quot;postgresql+psycopg://app-user:app-password@localhost:5432/app-store&quot;)

with engine.connect() as con:
    con.execute(text('Select 1;'))&gt;&gt;&gt; from sqlalchemy import text
&gt;&gt;&gt; 
&gt;&gt;&gt; engine = create_engine(&quot;postgresql+psycopg://app-user:app-password@localhost:5432/app-store&quot;)
&gt;&gt;&gt; 
&gt;&gt;&gt; with engine.connect() as con:
...     con.execute(text('Select 1;'))
..."><pre class="notranslate"><span class="pl-s1">create</span> <span class="pl-s1">some</span> <span class="pl-s1">new</span> <span class="pl-s1">project</span> <span class="pl-s1">dir</span> <span class="pl-c1">and</span> <span class="pl-s1">in</span> <span class="pl-s1">dir</span> 

$ <span class="pl-s1">pipenv</span> <span class="pl-s1">install</span> <span class="pl-s">"psycopg[binary]"</span>
$ <span class="pl-s1">pipenv</span> <span class="pl-s1">install</span> <span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-s1">pre</span> <span class="pl-v">SQLAlchemy</span>

$ <span class="pl-s1">docker</span> <span class="pl-s1">run</span> <span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-s1">rm</span> <span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-s1">name</span> <span class="pl-s1">some</span><span class="pl-c1">-</span><span class="pl-s1">postgres</span> <span class="pl-c1">-</span><span class="pl-s1">p</span> <span class="pl-c1">5432</span>:<span class="pl-c1">5432</span> <span class="pl-c1">-</span><span class="pl-s1">e</span> <span class="pl-v">POSTGRES_PASSWORD</span><span class="pl-c1">=</span><span class="pl-s1">mysecretpassword</span> <span class="pl-s1">postgres</span>

<span class="pl-s1">another</span> <span class="pl-s1">shell</span>
$ <span class="pl-s1">docker</span> <span class="pl-s1">exec</span> <span class="pl-c1">-</span><span class="pl-s1">it</span> <span class="pl-s1">some</span><span class="pl-c1">-</span><span class="pl-s1">postgres</span> <span class="pl-s1">bash</span>

$ <span class="pl-s1">psql</span> <span class="pl-c1">-</span><span class="pl-v">U</span> <span class="pl-s1">postgres</span>

<span class="pl-v">CREATE</span> <span class="pl-v">DATABASE</span> <span class="pl-s">"app-store"</span>;
<span class="pl-v">CREATE</span> <span class="pl-v">USER</span> <span class="pl-s">"app-user"</span> <span class="pl-v">WITH</span> <span class="pl-v">ENCRYPTED</span> <span class="pl-v">PASSWORD</span> <span class="pl-s">'app-password'</span>;
<span class="pl-v">GRANT</span> <span class="pl-v">ALL</span> <span class="pl-v">PRIVILEGES</span> <span class="pl-v">ON</span> <span class="pl-v">DATABASE</span> <span class="pl-s">"app-store"</span> <span class="pl-v">TO</span> <span class="pl-s">"app-user"</span>;

<span class="pl-s1">again</span> <span class="pl-c1">in</span> <span class="pl-s1">project</span> <span class="pl-s1">dir</span> <span class="pl-s1">shell</span>

$ <span class="pl-s1">pipenv</span> <span class="pl-s1">shell</span>
$ <span class="pl-s1">python</span>
$ <span class="pl-s1">python</span>
<span class="pl-v">Python</span> <span class="pl-c1">3.8</span><span class="pl-c1">.10</span> (<span class="pl-s1">default</span>, <span class="pl-v">Nov</span> <span class="pl-c1">14</span> <span class="pl-c1">2022</span>, <span class="pl-c1">12</span>:<span class="pl-c1">59</span>:<span class="pl-c1">47</span>) 
[<span class="pl-v">GCC</span> <span class="pl-c1">9.4</span><span class="pl-c1">.0</span>] <span class="pl-s1">on</span> <span class="pl-s1">linux</span>
<span class="pl-v">Type</span> <span class="pl-s">"help"</span>, <span class="pl-s">"copyright"</span>, <span class="pl-s">"credits"</span> <span class="pl-c1">or</span> <span class="pl-s">"license"</span> <span class="pl-k">for</span> <span class="pl-s1">more</span> <span class="pl-s1">information</span>.
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-k">from</span> <span class="pl-s1">sqlalchemy</span> <span class="pl-s1">import</span> <span class="pl-s1">create_engine</span>
<span class="pl-s1">my</span> <span class="pl-k">import</span> <span class="pl-s1">text</span>

<span class="pl-s1">engine</span> <span class="pl-c1">=</span> <span class="pl-en">create_engine</span>(<span class="pl-s">"postgresql+psycopg://app-user:app-password@localhost:5432/app-store"</span>)

<span class="pl-s1">with</span> <span class="pl-s1">engine</span>.<span class="pl-en">connect</span>() <span class="pl-k">as</span> <span class="pl-s1">con</span>:
    <span class="pl-s1">con</span>.<span class="pl-en">execute</span>(<span class="pl-en">text</span>(<span class="pl-s">'Select 1;'</span>))<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-k">from</span> <span class="pl-s1">sqlalchemy</span> <span class="pl-s1">import</span> <span class="pl-s1">text</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> 
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">engine</span> <span class="pl-c1">=</span> <span class="pl-en">create_engine</span>(<span class="pl-s">"postgresql+psycopg://app-user:app-password@localhost:5432/app-store"</span>)
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> 
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-k">with</span> <span class="pl-s1">engine</span>.<span class="pl-en">connect</span>() <span class="pl-k">as</span> <span class="pl-s1">con</span>:
...     <span class="pl-s1">con</span>.<span class="pl-en">execute</span>(<span class="pl-en">text</span>(<span class="pl-s">'Select 1;'</span>))
...</pre></div>
<h3 dir="auto">Error</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# Copy complete stack trace and error message here, including SQL log output if applicable."><pre class="notranslate"><code class="notranslate"># Copy complete stack trace and error message here, including SQL log output if applicable.
</code></pre></div>
<h3 dir="auto">Versions</h3>
<ul dir="auto">
<li>OS: Ubuntu 20.04.5 LTS</li>
<li>Python: Python 3.8.10</li>
<li>SQLAlchemy: 2.0.0rc2</li>
<li>Database: PostgreSQL 15.0 (Debian 15.0-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit</li>
<li>DBAPI (eg: psycopg, cx_oracle, mysqlclient): psycopg</li>
</ul>
<h3 dir="auto">Additional context</h3>
<blockquote>
<blockquote>
<blockquote>
<p dir="auto">import psycopg<br>
psycopg.<strong>version</strong><br>
'3.1.8'</p>
</blockquote>
</blockquote>
</blockquote>
<p dir="auto">looks like 3.1.8 adds a typecheck for TypeInfo.fetch</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="INTERNALERROR&gt;   File &quot;/home/classic/dev/sqlalchemy/lib/sqlalchemy/engine/create.py&quot;, line 746, in first_connect
INTERNALERROR&gt;     dialect.initialize(c)
INTERNALERROR&gt;   File &quot;/home/classic/dev/sqlalchemy/lib/sqlalchemy/dialects/postgresql/psycopg.py&quot;, line 356, in initialize
INTERNALERROR&gt;     info = self._type_info_fetch(connection, &quot;hstore&quot;)
INTERNALERROR&gt;            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR&gt;   File &quot;/home/classic/dev/sqlalchemy/lib/sqlalchemy/dialects/postgresql/psycopg.py&quot;, line 342, in _type_info_fetch
INTERNALERROR&gt;     return TypeInfo.fetch(connection.connection, name)
INTERNALERROR&gt;            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR&gt;   File &quot;/home/classic/.venv311/lib/python3.11/site-packages/psycopg/_typeinfo.py&quot;, line 86, in fetch
INTERNALERROR&gt;     raise TypeError(
INTERNALERROR&gt; TypeError: expected Connection or AsyncConnection, got _AdhocProxiedConnection"><pre class="notranslate"><span class="pl-v">INTERNALERROR</span><span class="pl-c1">&gt;</span>   <span class="pl-v">File</span> <span class="pl-s">"/home/classic/dev/sqlalchemy/lib/sqlalchemy/engine/create.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">746</span>, <span class="pl-s1">in</span> <span class="pl-s1">first_connect</span>
<span class="pl-v">INTERNALERROR</span><span class="pl-c1">&gt;</span>     <span class="pl-s1">dialect</span>.<span class="pl-en">initialize</span>(<span class="pl-s1">c</span>)
<span class="pl-v">INTERNALERROR</span><span class="pl-c1">&gt;</span>   <span class="pl-v">File</span> <span class="pl-s">"/home/classic/dev/sqlalchemy/lib/sqlalchemy/dialects/postgresql/psycopg.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">356</span>, <span class="pl-s1">in</span> <span class="pl-s1">initialize</span>
<span class="pl-v">INTERNALERROR</span><span class="pl-c1">&gt;</span>     <span class="pl-s1">info</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-en">_type_info_fetch</span>(<span class="pl-s1">connection</span>, <span class="pl-s">"hstore"</span>)
<span class="pl-v">INTERNALERROR</span><span class="pl-c1">&gt;</span>            <span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span>
<span class="pl-v">INTERNALERROR</span><span class="pl-c1">&gt;</span>   <span class="pl-v">File</span> <span class="pl-s">"/home/classic/dev/sqlalchemy/lib/sqlalchemy/dialects/postgresql/psycopg.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">342</span>, <span class="pl-s1">in</span> <span class="pl-s1">_type_info_fetch</span>
<span class="pl-v">INTERNALERROR</span><span class="pl-c1">&gt;</span>     <span class="pl-s1">return</span> <span class="pl-v">TypeInfo</span>.<span class="pl-en">fetch</span>(<span class="pl-s1">connection</span>.<span class="pl-s1">connection</span>, <span class="pl-s1">name</span>)
<span class="pl-v">INTERNALERROR</span><span class="pl-c1">&gt;</span>            <span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span><span class="pl-c1">^</span>
<span class="pl-v">INTERNALERROR</span><span class="pl-c1">&gt;</span>   <span class="pl-v">File</span> <span class="pl-s">"/home/classic/.venv311/lib/python3.11/site-packages/psycopg/_typeinfo.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">86</span>, <span class="pl-s1">in</span> <span class="pl-s1">fetch</span>
<span class="pl-v">INTERNALERROR</span><span class="pl-c1">&gt;</span>     <span class="pl-s1">raise</span> <span class="pl-v">TypeError</span>(
<span class="pl-v">INTERNALERROR</span><span class="pl-c1">&gt;</span> <span class="pl-v">TypeError</span>: <span class="pl-s1">expected</span> <span class="pl-v">Connection</span> <span class="pl-c1">or</span> <span class="pl-v">AsyncConnection</span>, <span class="pl-s1">got</span> <span class="pl-s1">_AdhocProxiedConnection</span></pre></div>
<p dir="auto">that's our wrapper so we have to unwrap one more level</p>