You can set environment variables for a project by adding a special type of Integration. Go to Integrations in the right-hand sidebar, and then either modify an existing "Environment variables" integration or add a new one:
Environment variables are a secure way to store secrets. They are stored encrypted, and decrypted only before mounting them into your project.
Don't forget to connect your project(s) to the newly created "Environment variable" from within the project itself. Once added to the project, you can easily use the Environment Variable from within your notebook:
import os os.environ.get("VARIABLE_NAME")
You might be storing your data in a database that does not yet have a native integration in Deepnote. Or perhaps you need to use a third-party library that issues an API key (e.g. Mailgun).
In this case, you can add an environment variable which will let you access the remote integration or third party service. An example is Deepnote's neptune.ai integration.
The environment variables from the Integrations are not available in Terminal sessions out of box.
You can use following command in the Terminal to set the environment variables in your Terminal session:
Please note that the environment variables are not automatically injected into the running Terminal sessions when a new integration is connected to your running project. You need to rerun the command above to set the variables.