title: SQL concatenating with python
body: <p>I am trying to update my mysql database field with a concatenation. I have to read my file line by line, and i need to append the existing string with the loaded line. I have to do it like this because my goal is to insert a 3gb long whitespace separated text file into one longtext field, and mysql only capable of handling 1gb text to insert.</p>
  
  <p>The problem with my code is that if i add the field name to the concat function like <code>seq=concat(seq, %s)</code> I get a SQL syntax error, but when I add the field name as a variable, python acts like it's a string. </p>
  
  <p>So short story long with this input file:</p>
  
  <pre><code>aaa
  bbb
  ccc
  </code></pre>
  
  <p>I want to have an updated mysql field like this:
  <code>aaabbbccc</code></p>
  
  <p>But I get this: <code>seqccc</code></p>
  
  <p>Any idea how should i work with the fieldname to get this work?</p>
  
  <pre><code>import mysql.connector
  
  connection = mysql.connector.connect(host='localhost',
                                           database='sys',
                                           user='Pannka',
                                           password='???')
  
  cursor = connection.cursor()
  with open('test.txt', 'r') as f:
      for line in f:
          sql = "update linedna set seq=concat(%s, %s) where id=1"
          val=('seq', line.rstrip())
          print(line.rstrip())
          cursor.execute(sql, val)
          connection.commit()
  
  cursor.close()
  connection.close()
  f.close()
  print(0)
  </code></pre>