input: Write a function to generate an HTML table displaying information about the top 10 bestselling books in a specific genre from a given SQLite database table named Books, which contains columns id (int), title (string), author (string), genre (string), and sales (int). If the specific genre has fewer than 10 books, the function should return an HTML table showing only the available books. If the genre has no books, the function should return an empty string.
  
  def generate_top_books_table(genre: str) -> str:
      import sqlite3
  
      # connect to the database
      conn = sqlite3.connect('books.db')
      c = conn.cursor()
  
      # retrieve the data
      c.execute('''SELECT title, author, genre, sales
      FROM Books
      WHERE genre=?
      ORDER BY sales DESC
      LIMIT 10''', (genre,))
  
      # save the results
      results = c.fetchall()
  
      # generate the HTML code
      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>'
  
      # close the connection
      conn.close()
  
      return html
  
  assert generate_top_books_table('Fantasy') != ''
  assert generate_top_books_table('Non-existent-genre') == ''
  assert '<table><tr><th>Title</th><th>Author</th><th>Genre</th><th>Sales</th></tr>' in generate_top_books_table('Mystery')
output: def generate_top_books_table(genre: str) -> str:
      import sqlite3
  
      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()
  
      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>'
  
      conn.close()
  
      return html if results else ''