title: python not correctly save data if I use pypyodbc
body: <p>I wrote a simple script for parsing csv and insert data into SQL Server.
  So, the very strange issue is that some variables are lost if I call them in a <em>if condition</em>.
  This is the script:</p>
  
  <pre><code># DB connection
  conn = pypyodbc.connect('DRIVER={SQL Server};SERVER=xxx.xxx.xxx.xxx;DATABASE=SCAN;UID=user;PWD=password')
  cursor = conn.cursor()
  
  def main() :
      reader = csv.reader(file(filename, "rb"), delimiter=';')
      for row in reader :
          ip = row[0]
          host = row[1]
          domain = row[2]
  
          # get Operating System ID
          os_id = getOperatingSystem(row[3])
  
          manufacturer = row[4]
          model = row[5]
  
          # get computer_manufacturer ID
          computer_manufacturer = getManufacturer(manufacturer, computer_model)
  
          arch = getArch(row[6])
  
          values = [ip, host, domain, os_id, manufacturer, arch]
  
          hostIP = getHostIP(ip)
          print "hostIP: " +str(hostIP)
          if hostIP == 0:
  
              print values
  
              # insert values in DB
              cursor.execute(
                  """
                  INSERT INTO dbo.hosts (ip, host, domain, os_id, manufacturer, arch_id)
                  VALUES (?, ?, ?, ?, ?, ?)
                  """, values)
              cursor.commit()
  
  
  # return host IP ID
  def getHostIP(hostIP) :
      cursor.execute("SELECT id FROM mytable WHERE ip = ?", [hostIP])
      row = cursor.fetchone()
  
      if row is not None :
          return row[0]
      return 0
  
  # return ID of Computer Manufacturer
  def getComputerManufacturer(manufacturer, computer_model) :
      cursor.execute("SELECT id FROM manufacturer WHERE manufacturer = ? AND computer_model = ?", [manufacturer, computer_model])
      row = cursor.fetchone()
  
      if row is not None:
          return row[0]
      else :
          return setComputerManufacturer(manufacturer, computer_model)
  </code></pre>
  
  <p>If I commented <em>cursor_execute</em> and <em>cursor_commit</em> lines the <em>print values</em> correctly shows data, else it shows only the same csv line.
  Can you give me a little help?
  Thanks</p>