Python, storing a list and inserting into one column of table
<p>The file I am reading in is formatted as follows:</p>

<pre><code>12       #block belonging to ID1
78
60
98
7

65      #block belonging to ID2
14
22
</code></pre>

<p>Each block is terminated by a blank line and each block belongs to one ID. I want to insert this info into a table with two fields ID_from (which is the ID of the block is belongs to) and ID_to(the numbers within the block). So for ex:</p>

<pre><code>ID_from    ID_to
1          12
1          78
1          60
1          98
1          7
2          65
2          14
2          22
</code></pre>

<p>I have a composite primary key which is the combination of these two fields which allows me to repeat the same ID in the ID_from column. This is my code relevant to the question:</p>

<pre><code>citations = line
my_list = []
        my_list.append(citations)
        my_list = " ".join(my_list)

db1.execute('''INSERT INTO citations(
                        ID_from, ID_to) VALUES(%s,%s)''',
                        (ID, my_list))

conn.commit()
</code></pre>

<p>(ID has be defined earlier in the code). What I believe to have achieved with this code is created a list- citations_collect[] and appended each line of a block to the list- essentially a list of all values that should be inserted into the ID_to column. The current output I am getting is just the last value in each block and its corresponding block ID it appears in. ie:</p>

<pre><code>ID_from    ID_to
1           7
2           22
</code></pre>

<p>My guess is that I should be putting my execute query into a loop but I am not certain of what the loop should consist of. What I was trying to do with the join function was to store the values of each block in a list on one line separated by a space and that would have been simpler to insert into a table but I hasnt made a difference to my output. 
I am new to python and mysql so I appreciate any feedback!</p>