beoliver
beoliver

Reputation: 5759

json or sqlite3 for a dictionary

I am playing around with python and thought I would make a simple language learning program... ie: lanuageA | languageB | type of word | synonym | antonym |

basically flash cards...

I have made a crude version using python and json, and have just started playing with sqlite3... Is a database a better way to organize the information, and for pulling things out and referencing against each other. and against user input. Or would it be easier to use nested dictionaries?

Upvotes: 2

Views: 484

Answers (2)

Dzinx
Dzinx

Reputation: 57874

Who is going to modify your data?

  • If you plan to only modify the word set yourself (as a developer, not a user of an application), you can use JSON to keep the data on the disk
  • If you want to allow users of your application to add/edit/remove flashcards, you should use a database (sqlite3 is OK), because otherwise you would have to save the whole data file after each small change made by the user. You could, of course, split the data into separate JSON files, add thread locks, etc., but that's what database engines are for.

Upvotes: 1

jcollado
jcollado

Reputation: 40424

If your data fits in memory and you only require to access elements by key, a dictionary is probably just enough for your needs.

Upvotes: 0

Related Questions