-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Saving the time entries in a SQLite DB initially makes sense as it provides convenient aggregation functions. In contrast, it obscures the data and makes it harder to manually make changes to entries. Additionally, it clutters the Python code with SQL.
So there are two possible solutions to this:
- Store the entries in a flat file in either JSON or YAML format. JSON support is built into Python, so no additional libraries there, but YAML is much more user-friendly for manual editing, supports advanced features like references, aliasing and custom objects, so perhaps that would be a better option. The drawback with this is that all the current aggregation would have to converted to Python.
- Keep the entries in a SQLite DB, but add a small ORM like peewee. This would avoid dealing with SQL for the most part, but could have a performance overhead. Benchmark this.
A third option could be a combination of the above two: give the storage option to the user. Implement the models as regular Peewee models, and if the user chooses JSON/YAML, use an in-memory SQLite DB and (de)serialize from/to JSON/YAML. If they choose SQLite3, no extra (de)serialization step is needed.
Doing it this way avoids dealing with plain SQL, keeps the benefits of using a DB, and even expands the storage options to Postgres or MySQL, because of Peewee support.