Reading Database Queries into a Specific format in Python
<p>Hi I'm connecting to sqlite database using python and fetching some results. However to input these results to another file I need it to be in the following format.</p>

<pre><code>     x={
     (1,1):1, (1,2):0,  
     (2,1):1, (2,2):0, 
     (3,1):0, (3,2):1, 
     (4,1):0, (4,2):1,}
</code></pre>

<p>My database table has only two rows (id (integer) and task (integer)). So I run the query "select * from allocation" and the result I get required to be formatted as above.</p>

<p>For instance allocation table is as follows:</p>

<pre><code>    id | task
    1  | 1
    2  | 1
    3  | 2
    4  | 2
</code></pre>

<p>Please Help.</p>