Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single-file storage for a Python application

Tags:

python

storage

I'm starting the development of a Python application that provides a GUI for editing various graphical and numerical entities (it's a configuration and management tool for mobile robots, if you must know). One of the questions is how to store the data for a project (meaning, for a robot). The data quantity will be low (about 10MB max) and quite heterogeneous (geometrical data of the robot, maps, missions, platform logs, recorded sensor data, project preferences, ...).

I don't want to develop my own storage layer. The project data should be stored in a single file, and easily accessible from Python. Storing updates should be cheap: I don't want to use an explicit "Save" operation, and changes should be stored as soon as they happen.

A single ZIP file is probably not practical, and would require writing a persistence layer on top to map the application objects to the storage. SQLite is an obvious candidate, possibly with SQLAlchemy as an object-relational layer. ZODB also looks interesting, but I have no experience with it so far.

Any recommendations?

EDIT: When I say an "application", I mean a program to be installed on a user's computer, not a web application.

EDIT: I will be opening data files created by other (not necessarily trusted) people, similar to what I would do with Word or PDF files. This must be a safe operation.

like image 357
Remy Blank Avatar asked Jan 21 '23 12:01

Remy Blank


1 Answers

shelve gives a mapping interface that allows you to store any pickleable type.

like image 137
Ignacio Vazquez-Abrams Avatar answered Feb 03 '23 00:02

Ignacio Vazquez-Abrams