input: Write a function to generate an HTML table displaying information about the top 10 bestselling books in a specific genre. The function should connect to a SQLite database, retrieve the relevant data, and construct an HTML table to display the results. If the database connection fails, the function should return an empty string.
  
  import sqlite3
  
  def generate_top_10_bestsellers_html(genre):
      try:
          # connect to the database
          conn = sqlite3.connect('books.db')
          c = conn.cursor()
  
          # retrieve the data
          c.execute(f'''SELECT title, author, genre, sales
                          FROM Books
                          WHERE genre='{genre}'
                          ORDER BY sales DESC
                          LIMIT 10''')
          
          # 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
      except sqlite3.Error:
          return ''
  
  assert generate_top_10_bestsellers_html('Fantasy') == '<table><tr><th>Title</th><th>Author</th><th>Genre</th><th>Sales</th></tr><tr><td>Book1</td><td>Author1</td><td>Fantasy</td><td>1000</td></tr><tr><td>Book2</td><td>Author2</td><td>Fantasy</td><td>900</td></tr><tr><td>Book3</td><td>Author3</td><td>Fantasy</td><td>800</td></tr><tr><td>Book4</td><td>Author4</td><td>Fantasy</td><td>700</td></tr><tr><td>Book5</td><td>Author5</td><td>Fantasy</td><td>600</td></tr><tr><td>Book6</td><td>Author6</td><td>Fantasy</td><td>500</td></tr><tr><td>Book7</td><td>Author7</td><td>Fantasy</td><td>400</td></tr><tr><td>Book8</td><td>Author8</td><td>Fantasy</td><td>300</td></tr><tr><td>Book9</td><td>Author9</td><td>Fantasy</td><td>200</td></tr><tr><td>Book10</td><td>Author10</td><td>Fantasy</td><td>100</td></tr></table>'
  assert generate_top_10_bestsellers_html('Mystery') == '<table><tr><th>Title</th><th>Author</th><th>Genre</th><th>Sales</th></tr><tr><td>MysteryBook1</td><td>MysteryAuthor1</td><td>Mystery</td><td>1200</td></tr><tr><td>MysteryBook2</td><td>MysteryAuthor2</td><td>Mystery</td><td>1100</td></tr><tr><td>MysteryBook3</td><td>MysteryAuthor3</td><td>Mystery</td><td>1000</td></tr><tr><td>MysteryBook4</td><td>MysteryAuthor4</td><td>Mystery</td><td>900</td></tr><tr><td>MysteryBook5</td><td>MysteryAuthor5</td><td>Mystery</td><td>800</td></tr><tr><td>MysteryBook6</td><td>MysteryAuthor6</td><td>Mystery</td><td>700</td></tr><tr><td>MysteryBook7</td><td>MysteryAuthor7</td><td>Mystery</td><td>600</td></tr><tr><td>MysteryBook8</td><td>MysteryAuthor8</td><td>Mystery</td><td>500</td></tr><tr><td>MysteryBook9</td><td>MysteryAuthor9</td><td>Mystery</td><td>400</td></tr><tr><td>MysteryBook10</td><td>MysteryAuthor10</td><td>Mystery</td><td>300</td></tr></table>'
  assert generate_top_10_bestsellers_html('NonexistentGenre') == ''
  assert generate_top_10_bestsellers_html('') == ''
output: def generate_top_10_bestsellers_html(genre):
      try:
          conn = sqlite3.connect('books.db')
          c = conn.cursor()
          c.execute(f'''SELECT title, author, genre, sales
                          FROM Books
                          WHERE genre='{genre}'
                          ORDER BY sales DESC
                          LIMIT 10''')
          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
      except sqlite3.Error:
          return ''