title: Python - SQLite JSON1 load extension
body: <p>I want to use the json1 extension for SQLite within Python. According to the <a href="http://sqlite.org/json1.html" rel="noreferrer">official documentation</a>, it should be a loadable extension. I got the json1.c file from the <a href="http://sqlite.org/cgi/src/raw/ext/misc/json1.c?name=9799e4252b305edcbe659329eec3ca80ed85f968" rel="noreferrer">source</a> and compiled it into json1.so as per the <a href="http://sqlite.org/loadext.html#build" rel="noreferrer">official instructions</a> without any errors.</p>
  
  <pre><code>$ gcc -g -fPIC -shared json1.c -o json1.so
  </code></pre>
  
  <p>The trouble came up when I tried to load the extension in Python 2.7.12 (and 3.5.2) according to the <a href="http://docs.python.org/2/library/sqlite3.html" rel="noreferrer">sqlite3 documentation</a>.</p>
  
  <pre><code>&gt;&gt;&gt; import sqlite3
  &gt;&gt;&gt; con = sqlite3.connect(":memory:")
  &gt;&gt;&gt; con.enable_load_extension(True)
  &gt;&gt;&gt; con.load_extension("./json1.so")
  </code></pre>
  
  <p>I received the following traceback error message. I ran the Python interpreter from the folder with the json1.so file in it. Even though it seems like there should be more information due to the last colon, the following is the complete error message.</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  sqlite3.OperationalError: error during initialization:
  </code></pre>
  
  <p>Is it actually not possible to use json1 as a loadable extension within Python? Is my only option to recompile SQLite, pysqlite2, etc. as explained in <a href="http://charlesleifer.com/blog/using-the-sqlite-json1-and-fts5-extensions-with-python/" rel="noreferrer">this</a> blog post by Charles Leifer?</p>
  
  <p>EDIT:</p>
  
  <p>As it turns out, I was receiving the error because my machine already had this and other extensions already enabled. The action of enabling an already enabled extension triggered the error. So far, all linux computers  I have access to already have the json1 and fts5 extensions enabled in the SQLite that comes with Python. You can check which compile options have been used by connecting to a SQLite database and running the following query.</p>
  
  <pre><code>PRAGMA compile_options;
  </code></pre>