Create SQL database from dict with different features in python
<p>I have the following dict:</p>

<pre><code>base = {}
base['id1'] = {'apple':2, 'banana':4,'coconut':1}
base['id2'] = {'apple':4, 'pear':8}
base['id3'] = {'banana':1, 'tomato':2}
....
base['idN'] = {'pineapple':1}
</code></pre>

<p>I want to create a SQL database to store it. I normally use <code>sqlite</code> but here the number of variables (features in the dict) is not the same for all ids and I do not know all of them thus I cannot use the standard procedure.</p>

<p>Does someone know an easy way to do it ? </p>

<p>ids will get duplicated if you use the sql i would suggest use postgres as it has a jsonfield ypu can put your data there corresponding to each key. Assuming you are not constrained to use SQL.</p>

python sqlite dictionary