A Python library for simplifying the use of environment variables in your projects.
EnvModel provides a simple and intuitive way to define, manage, and access environment variables in your Python projects. It supports a variety of field types, including strings, integers, floats, booleans, JSON, and string lists.
To install EnvModel, run the following command:
pip install envmodelHere's a minimal example of how to use EnvModel:
from envmodel import EnvModel, StringField
class MyConfig(EnvModel):
api_key = StringField(name="API_KEY", required=True)
database_url = StringField(name="DATABASE_URL", default="sqlite:///example.db")
config = MyConfig()
print(config.api_key) # prints the value of API_KEY environment variable
print(config.database_url) # prints the value of DATABASE_URL environment variable or the default valueEnvModel supports the following field types:
StringField: A string field that can hold any string value.IntegerField: An integer field that can hold any integer value.FloatField: A float field that can hold any float value.BooleanField: A boolean field that can hold a boolean value.JsonField: A JSON field that can hold any JSON value.StringListField: A string list field that can hold a list of string values.IntegerListField: An integer list field that can hold a list of integer values.
See the Field Types documentation for more details.
We welcome contributions to EnvModel! Please check out the Contributing documentation for more information.
EnvModel is released under the Apache License 2.0.
See the CHANGELOG for a list of changes.