The Client class provides an interface to initialize, create, load and list Encrypted Indexes. Encrypted Indexes, in turn, expose data-related functionality such as upserting, querying, and deleting.
To create the client, you must define the backing store locations which it will use. At minimum, you must set an index_location (where the index will reside) and a config_location (where the index metadata will reside). For example:
Copy
Ask AI
import cyborgdb_core as cyborgdb# or import cyborgdb_lite as cyborgdb# Using `memory` storage for this example# `redis` and `postgres` are also supportedindex_location = cyborgdb.DBConfig("memory") # Where encrypted index is stored (for queries)config_location = cyborgdb.DBConfig("memory") # Where encrypted index config is stored (for config/loading)# Get your API keyapi_key = "your_api_key_here" # Replace with your actual API key# Create a clientclient = cyborgdb.Client( api_key=api_key, index_location=index_location, config_location=config_location)
You can get an API key from the CyborgDB Admin Dashboard. For more info, follow this guide.Bear in mind that all contents stored in the backing stores is end-to-end encrypted, meaning that no index contents will be stored in plaintext. For performance reasons, you may wish to use a “fast” backing store option for index_location, such as Redis.
If you wish to store encrypted items in the index, you will also need to set a item_location:
Copy
Ask AI
import cyborgdb_core as cyborgdb# or import cyborgdb_lite as cyborgdb# Using `redis` storage for the index and config# Using `postgres` storage for the itemsindex_location = cyborgdb.DBConfig(location="redis", connection_string="redis://localhost")config_location = cyborgdb.DBConfig(location="redis", connection_string="redis://localhost")item_location = cyborgdb.DBConfig(location="postgres", table_name="item_table", connection_string="host=localhost dbname=postgres")# Get your API keyapi_key = "your_api_key_here" # Replace with your actual API key# Construct the Client objectclient = cyborgdb.Client( api_key=api_key, index_location=index_location, config_location=config_location, items_location=item_location)
Item contents will be encrypted prior to being uploaded to the backing store. In most applications, these are accessed less frequently than the index, so a “slower” backing store option can be used, such as PostgreSQL.