I have written python code which involves the use of dictionaries. I now wish to store my processed data onto a local SQLite database, but can’t think of how to translate something like:
myDict[wordA] = [list of tuples (length changes per word)]
into SQL. I have changed myDict to be an SQL table with word being the first element, but I don’t know how to assign columns to a variable list.
Do I have to change the structure of the DB?
Any ideas would be great!
I would suggest you follow through a database tutorial like: http://www.quackit.com/database/tutorial/.
You’ll want to make two tables, one that contains the word values, and one that contains the tuples. The tuples should not be in a list, but all have a separate row.
You can link the tuples to the words using foreign keys. You can link multiple rows to the same word, in that way keeping the tuples from the list linked to a single word.
It would look like this, the foreign_key of the tuple table linking to the primary_key of the Word table:
This would correspond to