connect.env
connect.env
Environment variable resources.
Classes
Name | Description |
---|---|
EnvVars |
EnvVars
connect.env.EnvVars(self, ctx, content_guid)
Attributes
Name | Description |
---|---|
content_guid |
Methods
Name | Description |
---|---|
clear | Remove all environment variables. |
create | Create an environment variable. |
delete | Delete the environment variable. |
find | Find environment variables. |
items | |
update | Update environment variables. |
clear
connect.env.EnvVars.clear()
Remove all environment variables.
Examples
>>> clear()
create
connect.env.EnvVars.create(key, value, /)
Create an environment variable.
Set an environment variable with the provided key and value. If the key already exists, its value is overwritten without warning to the provided value.
Parameters
Name | Type | Description | Default |
---|---|---|---|
key | str | The name of the environment variable to create. | required |
value | str | The value assigned to the environment variable. | required |
Examples
>>> create(
"DATABASE_URL",
... "postgres://user:password@localhost:5432/database",
... ... )
delete
connect.env.EnvVars.delete(key, /)
Delete the environment variable.
Parameters
Name | Type | Description | Default |
---|---|---|---|
key | str | The name of the environment variable to delete. | required |
Examples
>>> delete("DATABASE_URL")
find
connect.env.EnvVars.find()
Find environment variables.
List the names of the defined environment variables.
Returns
Name | Type | Description |
---|---|---|
List[str] | Environment variable names. |
Notes
The Connect environment variables API does support retrieving the environment variable’s value.
Examples
>>> find()
'DATABASE_URL'] [
items
connect.env.EnvVars.items()
update
connect.env.EnvVars.update(other=(), /, **kwargs)
Update environment variables.
Updates environment variables with the provided key-value pairs. Accepts a dictionary, an iterable of key-value pairs, or keyword arguments to update the environment variables. All keys and values must be str types.
Parameters
Name | Type | Description | Default |
---|---|---|---|
other | dict, iterable of tuples | A dictionary or an iterable of key-value pairs to update the environment variables. By default, it is None. | () |
**kwargs | str | Additional key-value pairs to update the environment variables. | {} |
Raises
Name | Type | Description |
---|---|---|
TypeError | If the type of ‘other’ is not a dictionary or an iterable of key-value pairs. |
Examples
Update using keyword arguments:
>>> update(DATABASE_URL="postgres://user:password@localhost:5432/database")
Update using multiple keyword arguments:
>>> update(
="postgres://localhost:5432/database",
... DATABASE_URL="user",
... DATABASE_USERNAME="password",
... DATABASE_PASSWORD ... )
Update using a dictionary:
>>> update(
... {"DATABASE_URL": "postgres://localhost:5432/database",
... "DATABASE_USERNAME": "user",
... "DATABASE_PASSWORD": "password",
...
... } ... )
Update using an iterable of key-value pairs:
>>> update(
... ["DATABASE_URL", "postgres://localhost:5432/database"),
... ("DATABASE_USERNAME", "user"),
... ("DATABASE_PASSWORD", "password"),
... (
... ] ... )