input: Write a function to generate an HTML table displaying information about the top 10 bestselling books in a specific genre from a given SQL database. The function should accept the database connection, the genre, and the table name as parameters, and return the HTML table as a string.
  
  assert generate_top_books_table(conn, 'Fantasy', 'Books') == '<table><tr><th>Title</th><th>Author</th><th>Genre</th><th>Sales</th></tr><tr><td>Title1</td><td>Author1</td><td>Fantasy</td><td>1000</td></tr><tr><td>Title2</td><td>Author2</td><td>Fantasy</td><td>900</td></tr><tr><td>Title3</td><td>Author3</td><td>Fantasy</td><td>800</td></tr><tr><td>Title4</td><td>Author4</td><td>Fantasy</td><td>700</td></tr><tr><td>Title5</td><td>Author5</td><td>Fantasy</td><td>600</td></tr><tr><td>Title6</td><td>Author6</td><td>Fantasy</td><td>500</td></tr><tr><td>Title7</td><td>Author7</td><td>Fantasy</td><td>400</td></tr><tr><td>Title8</td><td>Author8</td><td>Fantasy</td><td>300</td></tr><tr><td>Title9</td><td>Author9</td><td>Fantasy</td><td>200</td></tr><tr><td>Title10</td><td>Author10</td><td>Fantasy</td><td>100</td></tr></table>'
  
  assert generate_top_books_table(conn, 'Mystery', 'Books') == '<table><tr><th>Title</th><th>Author</th><th>Genre</th><th>Sales</th></tr><tr><td>MysteryTitle1</td><td>MysteryAuthor1</td><td>Mystery</td><td>1200</td></tr><tr><td>MysteryTitle2</td><td>MysteryAuthor2</td><td>Mystery</td><td>1100</td></tr><tr><td>MysteryTitle3</td><td>MysteryAuthor3</td><td>Mystery</td><td>1000</td></tr><tr><td>MysteryTitle4</td><td>MysteryAuthor4</td><td>Mystery</td><td>900</td></tr><tr><td>MysteryTitle5</td><td>MysteryAuthor5</td><td>Mystery</td><td>800</td></tr><tr><td>MysteryTitle6</td><td>MysteryAuthor6</td><td>Mystery</td><td>700</td></tr><tr><td>MysteryTitle7</td><td>MysteryAuthor7</td><td>Mystery</td><td>600</td></tr><tr><td>MysteryTitle8</td><td>MysteryAuthor8</td><td>Mystery</td><td>500</td></tr><tr><td>MysteryTitle9</td><td>MysteryAuthor9</td><td>Mystery</td><td>400</td></tr><tr><td>MysteryTitle10</td><td>MysteryAuthor10</td><td>Mystery</td><td>300</td></tr></table>'
  
  assert generate_top_books_table(conn, 'Science Fiction', 'Books') == '<table><tr><th>Title</th><th>Author</th><th>Genre</th><th>Sales</th></tr></table>'
  
  assert generate_top_books_table(None, 'Fantasy', 'Books') == ''
output: def generate_top_books_table(conn, genre, table_name):
      if conn is None:
          return ''
      
      query = f"SELECT Title, Author, Genre, Sales FROM {table_name} WHERE Genre = %s ORDER BY Sales DESC LIMIT 10"
      cursor = conn.cursor()
      cursor.execute(query, (genre,))
      rows = cursor.fetchall()
      cursor.close()
      
      if not rows:
          return '<table><tr><th>Title</th><th>Author</th><th>Genre</th><th>Sales</th></tr></table>'
      
      html_table = '<table><tr><th>Title</th><th>Author</th><th>Genre</th><th>Sales</th></tr>'
      for row in rows:
          html_table += f'<tr><td>{row[0]}</td><td>{row[1]}</td><td>{row[2]}</td><td>{row[3]}</td></tr>'
      html_table += '</table>'
      
      return html_table