<p dir="auto"><strong>Migrated issue, originally created by Sebastian Rittau (<a href="https://github.com/srittau">@srittau</a>)</strong></p>
<p dir="auto">Please consider the following code:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from sqlalchemy import create_engine, Column
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from sqlalchemy.types import Integer, JSON


DeclarativeBase = declarative_base()


class Foo(DeclarativeBase):

    __tablename__ = &quot;foo&quot;

    id = Column(Integer, primary_key=True)
    json = Column(JSON)


engine = create_engine(&quot;sqlite:///&quot;)
engine.execute(&quot;CREATE TABLE foo(id INTEGER PRIMARY KEY, json JSON)&quot;)
engine.execute(&quot;INSERT INTO foo(id, json) VALUES(123, '\&quot;bar\&quot;')&quot;)
session = sessionmaker(bind=engine)()
session.query(Foo).first()"><pre class="notranslate"><code class="notranslate">from sqlalchemy import create_engine, Column
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from sqlalchemy.types import Integer, JSON


DeclarativeBase = declarative_base()


class Foo(DeclarativeBase):

    __tablename__ = "foo"

    id = Column(Integer, primary_key=True)
    json = Column(JSON)


engine = create_engine("sqlite:///")
engine.execute("CREATE TABLE foo(id INTEGER PRIMARY KEY, json JSON)")
engine.execute("INSERT INTO foo(id, json) VALUES(123, '\"bar\"')")
session = sessionmaker(bind=engine)()
session.query(Foo).first()
</code></pre></div>
<p dir="auto">Running this with SQLAlchemy 1.2.5 and Python 3.6.5rc1, I get the following traceback:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/sql/type_api.py&quot;, line 471, in _cached_result_processor
    return dialect._type_memos[self][coltype]
  File &quot;/usr/lib/python3.6/weakref.py&quot;, line 394, in __getitem__
    return self.data[ref(key)]
KeyError: &lt;weakref at 0x7f7466d6f688; to 'JSON' at 0x7f746a797588&gt;

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File &quot;/home/srittau/.PyCharm2017.3/config/scratches/scratch_13.py&quot;, line 22, in &lt;module&gt;
    session.query(Foo).first()
  File &quot;/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/orm/query.py&quot;, line 2789, in first
    ret = list(self[0:1])
  File &quot;/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/orm/query.py&quot;, line 2581, in __getitem__
    return list(res)
  File &quot;/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/orm/query.py&quot;, line 2889, in __iter__
    return self._execute_and_instances(context)
  File &quot;/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/orm/query.py&quot;, line 2912, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File &quot;/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 948, in execute
    return meth(self, multiparams, params)
  File &quot;/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/sql/elements.py&quot;, line 269, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File &quot;/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1060, in _execute_clauseelement
    compiled_sql, distilled_params
  File &quot;/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py&quot;, line 1215, in _execute_context
    result = context.get_result_proxy()
  File &quot;/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/engine/default.py&quot;, line 1008, in get_result_proxy
    return result.ResultProxy(self)
  File &quot;/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/engine/result.py&quot;, line 649, in __init__
    self._init_metadata()
  File &quot;/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/engine/result.py&quot;, line 678, in _init_metadata
    self._metadata = ResultMetaData(self, cursor_description)
  File &quot;/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/engine/result.py&quot;, line 215, in __init__
    num_ctx_cols, cols_are_ordered, textual_ordered)
  File &quot;/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/engine/result.py&quot;, line 379, in _merge_cursor_description
    in enumerate(result_columns)
  File &quot;/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/engine/result.py&quot;, line 378, in &lt;listcomp&gt;
    ) for idx, (key, name, obj, type_)
  File &quot;/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/engine/default.py&quot;, line 971, in get_result_processor
    return type_._cached_result_processor(self.dialect, coltype)
  File &quot;/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/sql/type_api.py&quot;, line 477, in _cached_result_processor
    d[coltype] = rp = d['impl'].result_processor(dialect, coltype)
  File &quot;/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/sql/sqltypes.py&quot;, line 2148, in result_processor
    json_deserializer = dialect._json_deserializer or json.loads
AttributeError: 'SQLiteDialect_pysqlite' object has no attribute '_json_deserializer'"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/sql/type_api.py", line 471, in _cached_result_processor
    return dialect._type_memos[self][coltype]
  File "/usr/lib/python3.6/weakref.py", line 394, in __getitem__
    return self.data[ref(key)]
KeyError: &lt;weakref at 0x7f7466d6f688; to 'JSON' at 0x7f746a797588&gt;

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/srittau/.PyCharm2017.3/config/scratches/scratch_13.py", line 22, in &lt;module&gt;
    session.query(Foo).first()
  File "/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 2789, in first
    ret = list(self[0:1])
  File "/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 2581, in __getitem__
    return list(res)
  File "/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 2889, in __iter__
    return self._execute_and_instances(context)
  File "/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 2912, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 948, in execute
    return meth(self, multiparams, params)
  File "/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 269, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1060, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1215, in _execute_context
    result = context.get_result_proxy()
  File "/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 1008, in get_result_proxy
    return result.ResultProxy(self)
  File "/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/engine/result.py", line 649, in __init__
    self._init_metadata()
  File "/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/engine/result.py", line 678, in _init_metadata
    self._metadata = ResultMetaData(self, cursor_description)
  File "/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/engine/result.py", line 215, in __init__
    num_ctx_cols, cols_are_ordered, textual_ordered)
  File "/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/engine/result.py", line 379, in _merge_cursor_description
    in enumerate(result_columns)
  File "/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/engine/result.py", line 378, in &lt;listcomp&gt;
    ) for idx, (key, name, obj, type_)
  File "/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 971, in get_result_processor
    return type_._cached_result_processor(self.dialect, coltype)
  File "/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/sql/type_api.py", line 477, in _cached_result_processor
    d[coltype] = rp = d['impl'].result_processor(dialect, coltype)
  File "/home/srittau/.virtualenvs/zc-api-3.6/lib/python3.6/site-packages/sqlalchemy/sql/sqltypes.py", line 2148, in result_processor
    json_deserializer = dialect._json_deserializer or json.loads
AttributeError: 'SQLiteDialect_pysqlite' object has no attribute '_json_deserializer'
</code></pre></div>
<p dir="auto">Line 2148 of <code class="notranslate">sqlalchemy/sql/sqltypes.py</code> reads:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="        json_deserializer = dialect._json_deserializer or json.loads"><pre class="notranslate"><code class="notranslate">        json_deserializer = dialect._json_deserializer or json.loads
</code></pre></div>
<p dir="auto">I suspect this is supposed to read</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="        json_deserializer = dialect._json_deserializer if hasattr(dialect, &quot;_json_deserializer&quot;) else json.loads"><pre class="notranslate"><code class="notranslate">        json_deserializer = dialect._json_deserializer if hasattr(dialect, "_json_deserializer") else json.loads
</code></pre></div>
<p dir="auto">to support dialects without native JSON support.</p>
<p dir="auto"><strong>Migrated issue, originally created by Shengjing Zhu (<a href="https://github.com/zhsj">@zhsj</a>)</strong></p>
<p dir="auto">sqlalchemy.types.JSON only supports PostgreSQL and MySQL. But since SQLite 3.9, it has json support, <a href="https://sqlite.org/json1.html" rel="nofollow">https://sqlite.org/json1.html</a></p>
<p dir="auto">I hope sqlalchemy can support json1 too.</p>