This project demonstrates an example implementation of Queryable Encryption for the PyMongo driver. To learn more about Queryable Encryption, see the Queryable Encryption section in the Server manual.
The following sections provide instructions on how to set up and run this project.
To run this sample app, you first need to install the following dependencies:
- MongoDB Server version 7.0 or later (you can also use MongoDB Atlas)
- Automatic Encryption Shared Library version 7.0 or later (MongoDB Download Center)
python3
pip
For more information on installation requirements for Queryable Encryption, see Installation Requirements.
-
Clone this repository
-
Create a file in the root of your directory named
.env
. -
Copy the contents of
.env.template
into the.env
file. -
Replace the placeholder values in the
.env
file with your own credentials. For more information on setting credentials, see Quick Start for local key provider credentials.Tip: The SHARED_LIB_PATH must point to the actual filename not the folder where it is located
e.g., export SHARED_LIB_PATH=/software/mongo_crypt_shared_v1-macos-arm64-enterprise-7.0.1/lib/mongo_crypt_v1.dylib
-
[Optional] Create a three-node replica set (if you're not using Atlas)
Note: If you are using mtools, you can create a replica set by running the following command:
mlaunch init --replicaset --nodes 3
-
In a shell, navigate to the directory where you cloned this repo.
-
Create a new Python environment
python3 -m venv env
-
Activate the new Python environment
source env/bin/activate
-
Run
python3 -m pip install -r requirements.txt
to install the Python driver andpymongocrypt
. -
Run
jupyter lab
to open Jupyter Lab and then open the file QE.ipynb. -
Follow the notebook to insert an encrypted document in MongoDB.
The original version of this tutorial is located here
To install the libmongocrypt on Mac OS:
brew install mongodb/brew/libmongocrypt
Also for Mac OS with M1, the Automatic Encryption Library direct download link is here