Changes between Version 1 and Version 2 of JSON1Extension
- Timestamp:
- May 10, 2020, 5:46:37 AM (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
JSON1Extension
v1 v2 5 5 ================================== 6 6 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::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:: 8 8 9 9 >>> import sqlite3 … … 24 24 - Download the `SQLite amalgamation`__, with or without the configuration script. 25 25 - 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::26 - Compile the source code using the ``-DSQLITE_ENABLE_JSON1`` flag to enable the JSON1 extension. For example:: 27 27 28 28 gcc -DSQLITE_ENABLE_JSON1 -c -fPIC sqlite3.c … … 33 33 gcc -shared -o libsqlite3.so -fPIC sqlite3.o -ldl -lpthread 34 34 35 - 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::35 - 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:: 37 37 38 38 export LD_PRELOAD=/usr/lib/sqlite3/libsqlite3.so … … 46 46 ===== 47 47 48 On macOS, follow the instructions for Linux above, but instead of setting the ` LD_PRELOAD` environment variable, use `DYLD_LIBRARY_PATH`. For example::48 On macOS, follow the instructions for Linux above, but instead of setting the ``LD_PRELOAD`` environment variable, use ``DYLD_LIBRARY_PATH``. For example:: 49 49 50 50 export DYLD_LIBRARY_PATH=/usr/lib/sqlite3 … … 54 54 55 55 - 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.57 - Enter the ` DLLs` directory in your Python installation.58 - Rename (or delete) ` sqlite3.dll` inside the `DLLs` directory.59 - Extract ` sqlite3.dll` from the downloaded DLL archive and put it in the `DLLs` directory.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. 57 - Enter the ``DLLs`` directory in your Python installation. 58 - Rename (or delete) ``sqlite3.dll`` inside the ``DLLs`` directory. 59 - Extract ``sqlite3.dll`` from the downloaded DLL archive and put it in the ``DLLs`` directory. 60 60 - Now, the JSON1 extension should be ready to be used in Python and Django. 61 61