EDIT: This post was marked as "duplicate," which I think missed my original point. So I have clarified my question, and I hope it will be re-opened.
I recently came across a situation in which I needed random access to a collection of Python objects. The collection did not fit in memory, so I consulted the Python documentation on object persistence.
The documentation mentions two options for non-serial persistence: shelve
and sqlite3
.
shelve
is a Python-specific library that works with some kind of Unix built-in. (I'm not familiar with the specifics.)sqlite3
is a widely supported, highly dependable mini-database that is used all over the place.
So my first reaction was to use sqlite3
, as it's highly flexible and has a rich ecosystem. But according to another SO discussion, storing pickled Python objects in sqlite3
is considered very bad form.
In the question marked above, it is noted that pickling data into sqlite3
prevents queries within that data. However, there's nothing stopping me from adding two, three, or many columns by means of which I could retrieve cross-sections of the data. shelve
does not enable this.
To me, this presents a whole range of use cases that shelve
simply does not offer. Nevertheless, in the post noted above, it is claimed that "doing this sort of thing is indicative of bad design," as well as a host of other judgmental statements.
My question is: why is this? Why is doing this a sign of unhealth? I can think of numerous use cases where I might want the flexibility and capacity of sqlite3
without the overhead of a full-fledged database system.