Changes between Version 2 and Version 3 of JSON1Extension


Ignore:
Timestamp:
Aug 14, 2020, 1:40:39 AM (4 years ago)
Author:
Sage Abdullah
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • JSON1Extension

    v2 v3  
    55==================================
    66
    7 To use **django.db.models.JSONField** on SQLite, you need to enable the `JSON1 extension`__ on Python's `sqlite3`__ library. If the extension is not enabled on your installation, a system error (``fields.E180``) will be raised. To check if the extension is enabled on your installation, you can do a query with one of the functions included in the extension, e.g. ``JSON()``. For example::
     7To use **django.db.models.JSONField** on SQLite, you need to enable the `JSON1 extension`__
     8on Python's `sqlite3`__ library. If the extension is not enabled on your installation, a system error
     9(``fields.E180``) will be raised. To check if the extension is enabled on your installation, you can
     10do a query with one of the functions included in the extension, e.g. ``JSON()``. For example::
    811
    912    >>> import sqlite3
     
    1215    >>> cursor.execute('SELECT JSON(\'{"a": "b"}\')')
    1316
    14 If the query doesn't throw any errors, then the JSON1 extension is already enabled. Otherwise, follow the instructions below according to your operating system to set it up correctly.
     17If the query doesn't throw any errors, then the JSON1 extension is already enabled. Otherwise,
     18follow the instructions below according to your operating system to set it up correctly.
    1519
    1620.. __: https://www.sqlite.org/json1.html
     
    2024=====
    2125
    22 On most major Linux distributions, the JSON1 extension is included in their SQLite and/or Python packages and enabled by default. If that's not the case on your installation, then do the following:
     26On most major Linux distributions, the JSON1 extension is included in their SQLite and/or Python
     27packages and enabled by default. If that's not the case on your installation, then do the following:
    2328
    2429- Download the `SQLite amalgamation`__, with or without the configuration script.
    2530- Extract the source code archive and enter the directory of the result.
    26 - Compile the source code using the ``-DSQLITE_ENABLE_JSON1`` flag to enable the JSON1 extension. For example::
     31- Compile the source code using the ``-DSQLITE_ENABLE_JSON1`` flag to enable the JSON1
     32  extension. For example::
    2733
    2834    gcc -DSQLITE_ENABLE_JSON1 -c -fPIC sqlite3.c
     
    3440
    3541- Place the resulting file (``libsqlite3.so``) in a desired directory, e.g. ``/usr/lib/sqlite3/``.
    36 - Set the ``LD_PRELOAD`` environment variable to use your compiled SQLite every time you run Django. For example::
     42- Set the ``LD_PRELOAD`` environment variable to use your compiled SQLite every time you run
     43  Django. For example::
    3744
    3845    export LD_PRELOAD=/usr/lib/sqlite3/libsqlite3.so
     
    4653=====
    4754
    48 On macOS, follow the instructions for Linux above, but instead of setting the ``LD_PRELOAD`` environment variable, use ``DYLD_LIBRARY_PATH``. For example::
     55`As of Python 3.7`__, the official Python installer on macOS already includes the JSON1
     56extension by default. If you're using an earlier version of Python, you can follow the instructions
     57for Linux above, but instead of setting the ``LD_PRELOAD`` environment variable, use
     58``DYLD_LIBRARY_PATH``. For example::
    4959
    5060    export DYLD_LIBRARY_PATH=/usr/lib/sqlite3
     61
     62.. __: https://github.com/python/cpython/commit/9625bf520e08828e36bc3b1d043af679eb5f993d
    5163
    5264Windows
    5365=======
    5466
     67`As of Python 3.9`__, the official Python installer on Windows already includes the JSON1
     68extension by default. If you're using an earlier version of Python, you can do the following:
     69
     70.. __: https://github.com/python/cpython/commit/58d6f2ee3aeb699156d4784acccd2910d27982e7
     71
    5572- Download the `precompiled DLL`__ that matches your Python installation (32-bit or 64-bit).
    56 - Locate your Python installation. By default, it should be in ``%localappdata%\Programs\Python\PythonXX``, where ``XX`` is the Python version. For example, it's located in ``C:\Users\<username>\AppData\Local\Programs\Python\Python37``. If you added Python installation directory to your ``PATH`` environment variable, you can run the command ``where python`` on a command prompt to locate it.
     73- Locate your Python installation. By default, it should be in
     74  ``%localappdata%\Programs\Python\PythonXX``, where ``XX`` is the Python version. For
     75  example, it's located in ``C:\Users\<username>\AppData\Local\Programs\Python\Python37``.
     76  If you added Python installation directory to your ``PATH`` environment variable, you can run the
     77  command ``where python`` on a command prompt to locate it.
    5778- Enter the ``DLLs`` directory in your Python installation.
    5879- Rename (or delete) ``sqlite3.dll`` inside the ``DLLs`` directory.
Back to Top