Using EdgeDB with Jupyter Notebook
-
Install the EdgeDB Python library with
pip install edgedb
-
Set the appropriate connection environment variables required for your EdgeDB instance
For EdgeDB Cloud instances
-
EDGEDB_INSTANCE
- your instance name (<org-name>/<instance-name>
) -
EDGEDB_SECRET_KEY
- a secret key with permissions for the selected instance.You may create a secret key with the CLI by running
edgedb cloud secretkey create
or in the EdgeDB Cloud UI.
For other remote instances
-
EDGEDB_DSN
- the DSN of your remote instanceDSNs take the following format:
edgedb://<username>:<password>@<hostname-or-ip>:<port>/<branch>
. Omit any segment, and EdgeDB will fall back to a default value listed in our DSN specification
For local EdgeDB instances
-
EDGEDB_INSTANCE
- your instance name -
EDGEDB_USER
&EDGEDB_PASSWORD
Usernames and passwords
EdgeDB creates an
edgedb
user by default, but the password is randomized. You may set the password for this role by runningalter role edgedb { set password := '<password>'; };
or you may create a new role usingcreate superuser role <name> { set password := '<password>'; };
. -
-
Start your notebook by running
jupyter notebook
. Make sure this process runs in the same environment that contains the variables you set in step 3. -
Create a new notebook.
-
In one of your notebook’s blocks, import the EdgeDB library and run a query.
Copyimport edgedb client = edgedb.create_client() def main(): query = "SELECT 1 + 1;" # Swap in any query you want result = client.query(query) print(result[0]) main() client.close()