title: SQL Data is fetched only once
body: <p>I have troubles while fetching data from a SQL-Database. The program gets data from a PHP-site and plays the sound if it is a youtube link. Currently, it has troubles when the database is empty. My goal is, that it exits the for-loop, what it does, but it does not receive any data and tries to fetch it once more until data is inserted by the site.</p>
  <pre><code>import mysql.connector
  import pafy
  import vlc
  import time
  from mysql.connector.errors import Error
  
  
  
  url = &quot;NULL&quot;
  
  try:
          connection = mysql.connector.connect(host='localhost',
                                               database='musicbox',
                                               user='',
                                               password='')
          if connection.is_connected():
                  db_Info = connection.get_server_info()
                  print(&quot;Connected to MySQL Server version &quot;, db_Info)
                  cursor = connection.cursor()
                  while True :
  
                          db_Info = connection.get_server_info()
                          print(&quot;Connected to MySQL Server version &quot;, db_Info)
  
                          cursor = connection.cursor()
                          print &quot;test2&quot;
                          cursor.execute(&quot;SELECT * FROM playlist&quot;)
                          record = cursor.fetchall()
                          print record
                          time.sleep(1)
                          for x in record:
                                  print x[0]
                                  if &quot;youtube&quot; in x[0]:
                                          if not all(x):
                                                  print &quot;empty&quot;
                                          else:
                                                  print &quot;true&quot;
                                                  url = x[0]
                                                  video = pafy.new(url)
                                                  best = video.getbestaudio()
                                                  playurl = best.url
                                                  Instance = vlc.Instance()
                                                  player = Instance.media_player_new()
                                                  Media = Instance.media_new(playurl)
                                                  Media.get_mrl()
                                                  player.set_media(Media)
                                                  player.play()
                                                  time.sleep(1.5)
                                                  duration = player.get_length() / 1000
                                                  time.sleep(duration)
                                                  cursor.execute(&quot;DELETE FROM playlist LIMIT 1&quot;)
                                                  connection.commit()
  
  except Error as e:
      print(&quot;Error while connecting to MySQL&quot;, e)
  finally:
      if (connection.is_connected()):
          cursor.close()
          connection.close()
          print(&quot;MySQL connection is closed&quot;)
  </code></pre>