Sort file instead of using database

I am writing a basic web application for membership in python.

Is it always possible to abandon databases completely and simply sort the python dictionary into a file (http://docs.python.org/2/library/pickle.html)? A program will never have to deal with more than approx. 500 members, and will only contain a few fields for each member, so I don’t see scaling being a problem. And since this application may need to be run locally, it is easier to make it run on different machines if everything is as simple as possible.

Thus, you need to configure mysql db or just sort the file. I would prefer the second, but I would like to know a terrible idea.

+7
source share
1 answer

No, if you can store all the data in memory, a database is not needed, and simply etching can work.

Noticeable etching flaws are that it is unsafe, someone can replace your data with something else, including executable code, and that it is only Python. With a database, you also usually update the data and write it to disk at the same time, while you have to remember to sort the data and save it to disk. Since this takes time when you write all the data at once, this is usually done only on exit, so a failure means that you lose all your changes.

There is a middle level: sqlite. This is a lightweight simple SQL database included with Python (since Python 2.5), so you do not need to install any additional software to use it. This is often a quick fix. Because SQLAlcehmey supports SQLite, this also means that you can even use SQLAlchemy with SQLite as the default database and therefore provide a "upgrade path" to more serious databases.

+11
source

All Articles