title: Trying to input a lot of Data into mysqldb
body: <pre><code>#!/usr/bin/env python
  
  from __future__ import print_function
  
  import pymysql.cursors
  
  Journal=open('J_15April.txt')
  
  jrn=Journal.read()
  
  Zeile=jrn.split('14.04.2015')
  
  conn = pymysql.connect(host='localhost', port=3306, user='root',passwd='',db='daten', cursorclass=pymysql.cursors.DictCursor)
  
  
  ean = int(row[0])
  smr = char(row[1])
  uhrzeit = char(row[2])
  
  
  for line in Zeile:
  cur = conn.cursor()
      if 'BOTTLE_ID' in line
  
          line2 = line.split(';')
  
          line3 = line2[0].strip(' BOTTLE_UNIQUE: BOTTLE_ID: 0')
  
          uhrzeit = (line3[:-4])
  
          if 'EAN' not in line:
              ean = 0
  
          else:
             ean = line2[7].strip('EAN: ')
  
  
          if ' SMR: 1;' in line:
              smr = ('gelesen')
  
          else:
              smr = ('nicht gelesen')
  
          cur.execute("INSERT INTO lga (ean, smr, uhrzeit) VALUES  ('%s','%s','%s')%(ean, smr, uhrzeit)")
          cur.fetchall()
  
  
  
  
  cur.close()
  conn.commit()
  conn.close()
  </code></pre>
  
  <p>Hi guys,</p>
  
  <p>I'm currently trying to put a lot of data into a mysqldb. I wrote two separate programs, one is for filtering the important stuff out of a very long .txt and the other one inserts them in the database.</p>
  
  <p>The actual problem now occured when I tried combine those two program to automatically read and insert the data. I think the structure of the shown program may be a little chaotic and that's the main reason why it is not working. I'm absolutely new to python and it was quite hard for me two make the two other programs work so please help me out. </p>
  
  <p>If you are interested in the two single functions I can post them as well.</p>
  
  <p>greetings </p>
  
  <p>trbo</p>
  
  <p><strong>Traceback</strong></p>
  
  <p>So this would be the Traceback when i run the code:</p>
  
  <p>Traceback (most recent call last):</p>
  
  <p>File "C:\Users\tristan.bonn\Desktop\Python\Verbindung mit mysql\Tabelle mit Daten füllen.2.py", line 17, in row = cur.fetchall()</p>
  
  <p>File "C:\Users\tristan.bonn\AppData\Local\Programs\Python\Python35\lib\site-packages\pymysql\cursors.py", line 256, in fetchall self._check_executed()</p>
  
  <p>File "C:\Users\tristan.bonn\AppData\Local\Programs\Python\Python35\lib\site-packages\pymysql\cursors.py", line 70, in _check_executed raise err.ProgrammingError("execute() first") pymysql.err.ProgrammingError: execute() first</p>