HBNetwork / python-decouple

Strict separation of config from code.
MIT License
2.82k stars 195 forks source link

question Changing settings #144

Closed NADOOITChristophBa closed 2 years ago

NADOOITChristophBa commented 2 years ago

I have a Question.

Sorry if this is the wrong place to ask questions I am still new to GitHub. Please if not, point me to the right one.

I was wondering if there is a way to use decouple to change a setting programmatically.

From the documentation, I would guess it is purely retrieval but what if my user wants to change a setting?

In my System, Users can add and change API_Keys that I would like to store in the settings file, but I don't want them to actually go to the file itself and instead use a program.

Something like config('API_KEY') = "12345" isn't possible right?

Currently, I am using .json files for storing the settings info and just found python-decouple and like the idea of using it. But if I can not change settings on the fly, it doesn't seem to provide the needed features.

Thanks in advance for the answer.

ascii-dev commented 2 years ago

Hi NADOOITChristophBa, I might not be entirely right about this, but from my experience of using this package, it only does retrieval and I haven't run into a case where it also writes and I don't think it has that capability. Also, I'm not sure why you'll want to store this information in a file where storing them in a database table would be easier to work with but I think the python file commands should be able to handle this just fine. Let me know if this works for you.

NADOOITChristophBa commented 2 years ago

Hello ascii-dev,

Thanks for the answer. True, now that you mention it, storing this information in something like an SQLite Database would be better. I guess I was looking for a one size fits all solution, while decouple is, to my understanding, more aimed at providing a way to store config settings that don't change.

I sometimes do that because I don't particularly appreciatee adding more and more tools to a project. Having just one way of doing things has been how I do things in my day job, where I had to build everything because there are no third-party packages for the language I work with.

I am still becoming accustomed to python and building tools by combining other people's work.

I looked at TinyDB to do this before finding decouple. I liked the syntax of decoupling better, so I thought that if it could do reads and writes, I could use that.

Thanks again.