input: Write a function to generate an HTML table displaying information about the top 10 bestselling books in a specific genre by connecting to a SQLite database. The function should connect to a database named 'books.db', execute a query to retrieve the top 10 books in the specified genre based on sales, and generate an HTML table with columns for title, author, genre, and sales. If no books match the genre, the function should return an empty string. If the database connection fails, the function should return an error message.
  def generate_html_table(genre):
      try:
          conn = sqlite3.connect('books.db')
          c = conn.cursor()
          c.execute('''SELECT title, author, genre, sales
                      FROM Books
                      WHERE genre=?
                      ORDER BY sales DESC
                      LIMIT 10''', (genre,))
          results = c.fetchall()
          if len(results) == 0:
              return ''
          html = '<table>'
          html += '<tr><th>Title</th><th>Author</th><th>Genre</th><th>Sales</th></tr>'
          for result in results:
              title = result[0]
              author = result[1]
              genre = result[2]
              sales = result[3]
              html += f'<tr><td>{title}</td><td>{author}</td><td>{genre}</td><td>{sales}</td></tr>'
          html += '</table>'
          return html
      except Exception as e:
          return f"Error: {str(e)}"
  
  assert generate_html_table('Fantasy') != ''
  assert generate_html_table('Non-existent-genre') == ''
  assert '<table>' in generate_html_table('Mystery')
  assert '<th>Title</th>' in generate_html_table('Sci-Fi')
output: def generate_html_table(genre):
      try:
          conn = sqlite3.connect('books.db')
          c = conn.cursor()
          c.execute('''SELECT title, author, genre, sales
                      FROM Books
                      WHERE genre=?
                      ORDER BY sales DESC
                      LIMIT 10''', (genre,))
          results = c.fetchall()
          if len(results) == 0:
              return ''
          html = '<table>'
          html += '<tr><th>Title</th><th>Author</th><th>Genre</th><th>Sales</th></tr>'
          for result in results:
              title = result[0]
              author = result[1]
              genre = result[2]
              sales = result[3]
              html += f'<tr><td>{title}</td><td>{author}</td><td>{genre}</td><td>{sales}</td></tr>'
          html += '</table>'
          return html
      except Exception as e:
          return f"Error: {str(e)}"