This might give you more flexibility if you choose another format. You might also consider abstracting how you communicate with the data store (file) so that QSortFilterProxyModel does not know which format you are using. Or if it works out store the whole thing as a database entry. Just store your sub JSON objects in the database and reassemble into higher tier objects. I have not used the SQL interface in Qt, but it does look like it abstracts at least the different database types just like SQLAlchemy does (at least the Qt 5.12 docs show this), but it looks like you have to deal with queries still.Īnyway, you don't have to choose JSON or not JSON. In python I used SQLAlchemy which abstracted the database to not have to deal with queries directly. I have used SQLite successfully in python applications. My QSortFilterProxyModel would do less work.ĭisadvantages of using a SQLite database:.Sorting and filtering can be done in a SQL command.The data stored on the user's computer would be JSON.ĭisadvantages of keeping every note, notebook, and tag in memory: I get to work with one format - The data sent to the cloud would be in JSON.I don't have to worry about SQL queries.It is very easy for me to filter and sort notes using QSortFilterProxyModel.Here are some advantages and disadvantages I figure of dealing with everything in memory vs using a database:Īdvantages of keeping data in memory and using JSON to store it This means I have to either store a JSON file on the users computer, store some sort of computer-readable object, or use a SQLite database. However, this app will also have offline editing capabilities. When a user connects there account, notes will be pulled down in JSON format. Why JSON? I have a Python rest API for cloud-syncing. The app startup time was not affected (Noticeably) and the memory usage was 50mb. This has worked fine so far and hasn't caused any noticeable performance problems. When you open the app, it will take the data in the JSON, create 'Note', 'Notebook', and 'Tag' instances (classes), and add them to a 'database' object that will manage the objects, send signals, etc. When I was creating the main functionality of the app, I starting with a bunch of dummy data (Notes, notebooks, and tags) loaded from JSON files. I'm currently working on an open-source note-taking app, Vibrato Notes, ( source code) and feel like I am at a bit of a crossroads with a software design choice. If the json1 extension is unavailable, then you could use the following as a starting point: awk 'BEGIN. (A less tiresome alternative might be to use the sqlite3 function json_array(), which produces an array, which you can reassemble into an object using jq.) You can then use a tool such as jq to convert the stream of objects into an array of objects, e.g. For example: select json_object('id', id, 'fname', fname, 'gname', gname, 'genderid', genderid). If your sqlite3 is compiled with the json1 extension (or if you can obtain a version of sqlite3 with the json1 extension), then you can use it to generate JSON objects (one JSON object per row).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |