G
G
Grandma Luda2021-10-09 12:31:01
Python
Grandma Luda, 2021-10-09 12:31:01

Are there other ways to store data?

For my application to work, I need to save one value (0 or 1), but in my opinion it is incorrect to allocate a database for this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-10-09
@KirasiH

If the value is associated with a specific user, use a simple file in the user's profile.
If the value is related to a particular installation, and you definitely have write permissions to your program directory (for example, it's portable), use a simple file in the program directory.
If you plan to run the program only on Windows, you can use the registry.
The file format depends on how likely it is to expand the set of stored data, and what kind of data you plan to store.
One value (any) is a regular file, either as text or as binary data.
Primitive types (strings, numbers, logic) - cfg file, configparser module.
The same plus lists and dictionaries - json file, json module.
A tree-like hierarchy, a mixture of primitive data types with small portions of binary ones - the pickle module.
Again, if strictly under Windows - the registry does an excellent job with binary data and tree-like hierarchies.
But if your hierarchy of data objects is not a tree, but a graph (especially if there are many-to-many relationships), then you can’t go anywhere without a database.
So, according to the conditions you described, a simple file in the program directory will do.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question