We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This is another try on #35.
An interesting idea would be to add a helper for mapping-like env values like:
DATABASE_URLS="SQLite3=sqlite://:memory:,PostgreSQL=postgres://postgres:postgres@localhost:5432/postgres"
to return the respective Python dict objects. Implementation can be as simple as:
dict
def parse_dict(value, *, item_sep=",", key_value_sep="="): def split_and_strip(value, sep): return list(map(str.strip, value.split(sep))) items = split_and_strip(value, item_sep) return dict(split_and_strip(item, key_value_sep) for item in items)
or a similar callable class.
Something similar is implemented in environs.
environs
https://github.com/sloria/environs/blob/31d944845f52a3f6298f4b42cef92c2c887fe0a2/src/environs/__init__.py#L224-L250
but personally I prefer python-decouple as it natively supports .env file auto-reading.
python-decouple
.env
The text was updated successfully, but these errors were encountered:
In the meantime, I found a workaround using Csv:
Csv
DATABASE_URLS = config( "DATABASE_URLS", cast=Csv( cast=functools.partial(str.split, sep="="), post_process=dict, ), )
Sorry, something went wrong.
No branches or pull requests
This is another try on #35.
An interesting idea would be to add a helper for mapping-like env values like:
to return the respective Python
dict
objects. Implementation can be as simple as:or a similar callable class.
Something similar is implemented in
environs
.https://github.com/sloria/environs/blob/31d944845f52a3f6298f4b42cef92c2c887fe0a2/src/environs/__init__.py#L224-L250
but personally I prefer
python-decouple
as it natively supports.env
file auto-reading.The text was updated successfully, but these errors were encountered: