title: UnboundLocalError: local variable 'rows' referenced before assignment
body: <p>i'm trying to make a database connection by an other script.
  But the script didn't work propperly.</p>
  
  <p>and if I do a 'print' on the rows then I get the value 'null'</p>
  
  <p>But if I use a 'select * from incidents' query then i get the result from the table incidents.</p>
  
  <p>import database</p>
  
  <pre><code>rows = database.database("INSERT INTO incidents VALUES(3 ,'test_title1', 'test',     TO_DATE('25-07-2012', 'DD-MM-YYYY'), CURRENT_TIMESTAMP, 'sector', 50, 60)")
  #print database.database()
  print rows
  </code></pre>
  
  <p>database.py script:</p>
  
  <pre><code>import psycopg2
  import sys
  import logfile
  
  def database(query):
  logfile.log(20, 'database.py', 'Executing...')  
  con = None
  
  try:        
      con = psycopg2.connect(database='incidents', user='ipfit5', password='test') 
  
      cur = con.cursor()
      #print query
  
      cur.execute(query)
      rows = cur.fetchall()
  
      con.commit()
  
  
  #test row does work
      #cur.execute("INSERT INTO incidents VALUES(3 ,'test_titel1', 'test', TO_DATE('25-07-2012', 'DD-MM-YYYY'), CURRENT_TIMESTAMP, 'sector', 50, 60)")
  
  except:
      logfile.log(40, 'database.py', 'Er is iets mis gegaan') 
      logfile.log(40, 'database.py', str(sys.exc_info()))
  
  finally:
  
      if con:
          con.close()
  return rows
  </code></pre>