title: python sqlite3, inserting row into table using data from another table
body: <p>There are many eaxmples of this, but in all cases that I saw they knew the names of the fields(columns). The two tables have exactly the same column/fields.</p>
  
  <p>My solution has solved my current problem but as you can see from the code, it might qualify for the 'most ridiculous code of the year' award.</p>
  
  <pre><code># Copy data from one table to another in the same database
  print '-' * 70
  print 'Copy data from one table to another in the same database\n'
  print '  Usefull for creating test data.'
  print '-' * 70
  
  import sqlite3
  
  connection = sqlite3.connect("table.sqlite")
  cursor = connection.cursor()
  
  source_table = 'table1'
  target_table = 'test_table1'
  
  stmt = "SELECT * FROM %s" % source_table
  
  cursor.execute(stmt)
  data = cursor.fetchall()
  
  for row in data:
      stmt = "insert into %s values " % target_table + str(row)
      stmt = stmt.replace("u'", '"')
      stmt = stmt.replace("'", '"')
      stmt = stmt.replace(' None', ' Null')
      cursor.execute(stmt)
      connection.commit()
  
  connection.close()
  </code></pre>
  
  <p>There must be a better (more reliable) way to do this.</p>