Is there something wrong with building a Python Pickle website?

I have been playing with this idea for a long time, but I have not seen any information about how people do it. I have a small website project where I need to upload and modify 1 object. This object is quite simple and should not exceed a few kilobytes. Instead of starting the database for this small amount of data, why not just use pickle and / or shelve to save that data and load it? I plan to use a micro-web framework such as Bottle or Hip Flask for a project.

Is there any reason not to use this method to load data? It only loads the pickle file when Apache starts up, so I don’t think the speed will be executed (faster than the db request).

Thanks for any input!

+6
python flask pickle shelve
source share
3 answers

There is no reason why you cannot implement saving objects through the standard Python pickle or shelve . Just make sure your objects are clean and reliable. Scalability can be a concern if your site is larger than your current size, but until then your idea should work fine. If that day comes, the next obvious step is to consider using Python with the excellent SQLite that comes preloaded with the latest versions of the language.

+3
source share

I would not write a direct line to the file directly. Too many low-level details to worry about. Check out Durus , ZODB , or this FriendFeed post about storing Python objects in MySQL.

Do not drop relational databases, but they give you a lot of hits right out of the box (even for simple projects).

+3
source share

In addition to the concurrency issues that you already know about, you must also ensure that the file is always in a consistent state. For example, if the server crashes in the middle of a file entry, what happens afterwards? This is a case that you need to consider and implement a solution if you are following this route.

+1
source share

All Articles