title: PyMySQL not Inserting Data
body: <p>I have a piece of code which is taking Windows logs and inserting various pieces of information into an mySQL database. The code is running perfectly with no errors, but does not actually input the data into the table. The table remains blank. I pulled my mySQL syntax from an example with some modification, so I'm not entirely sure what is going wrong. I have a feeling it has either to do with the data types, or some changes I made to the syntax.</p>
  
  <pre><code>import sys
  import pymysql
  import pymysql.cursors
  import win32evtlog # requires pywin32 pre-installed
  import win32evtlogutil 
  import time
  
  
  server = 'localhost' # name of the target computer to get event logs
  logtype = 'System' # 'Application' # 'Security'
  hand = win32evtlog.OpenEventLog(server,logtype)
  flags = 
  win32evtlog.EVENTLOG_BACKWARDS_READ|win32evtlog.EVENTLOG_SEQUENTIAL_READ
  events = win32evtlog.ReadEventLog(hand, flags,0)
  
  while True:
  for event in events:
      evt_tp = event.EventType
      if evt_tp != (1 or 2 or 8):
              eve_cat = str(('Event Category:', event.EventCategory))
              eve_timegen = str(('Time Generated:', event.TimeGenerated))
              eve_srcnm =  str(('Source Name:', event.SourceName))
              eve_id = str(('Event ID:', event.EventID))
              eve_typ =  str(('Event Type:', event.EventType))
              data = event.StringInserts
              if data:
                  print ('Event Data:')
                  for msg in data:
                      print(msg)
  
              print(type(eve_cat))
              print(type(eve_timegen))
              print(type(eve_srcnm))
              print(type(eve_id))
              print(type(eve_typ))
              print(type(data))
              time.sleep(10)
  
      else:
          eve_cat = ('Event Category:', event.EventCategory)
          eve_timegen = ('Time Generated:', event.TimeGenerated)
          eve_srcnm =  ('Source Name:', event.SourceName)
          eve_id = ('Event ID:', event.EventID)
          eve_typ =  ('Event Type:', event.EventType)
          data = event.StringInserts
          print('There were no errors found')
  
          print(eve_cat)
          print(eve_timegen)
          print(eve_srcnm)
          print(eve_id)
          print(eve_typ)
          print(data)
          time.sleep(10)
  
  
  # Connect to the database
  connection = pymysql.connect(host='localhost',
                           user='root',
                           password='',
                           db='ptest',
                           charset='utf8mb4',
                           cursorclass=pymysql.cursors.DictCursor)
  
  
  
  try:
      with connection.cursor() as cursor:
      # Create a new record
          sql = "INSERT INTO `win_logs` (`Category`, `TimeGenerated`, 'SourceName', 
  'EventID', 'Type') VALUES (%s, %s, %s, %s, %s)"
      cursor.execute(sql, (eve_cat, eve_timegen, eve_srcnm, eve_id, eve_typ))
  
  # connection is not autocommit by default. So you must commit to save
  # your changes.
  
  connection.commit()
  
  with connection.cursor() as cursor:
      # Read a single record
      sql = "SELECT `id`, `Type` FROM `win_logs` WHERE `Category`=%s"
      cursor.execute(sql, ('webmaster@python.org',))
      result = cursor.fetchone()
      print(result)
  finally:
  connection.close()
  </code></pre>