runpython in html face - ModuleNotFoundError: No module named 'mysql'

Advertisement

fdu_account
Joined:
Posts:
1

runpython in html face - ModuleNotFoundError: No module named 'mysql'

I'm holding html file on winSCP

Such as
<html>
    <head>
      <link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
      <script defer src="https://pyscript.net/latest/pyscript.js"></script>
    </head>

  <body>
    <b><p>title <u><label id="AAA"></label></u> </p></b>
    <br/>
  
    <py-config>

      packages = ["mysql","mysql.connector"]
    </py-config>


 <py-script>
        import mysql.connector

        mydb = mysql.connector.connect(
          host="196.168.100.141",
          user="root",
          password="password123", 
          database="database_db",  
          auth_plugin='mysql_native_password'
        )
                        
        mycursor = mydb.cursor()
        mycursor.execute("SELECT * FROM database")                       
                                                 
        myresult = mycursor.fetchall()
        
        list_01 = []
        
        for row in myresult:
          print(row[0])


    </py-script>
  </body>
</html>

goal: the html can execute python script in order to get data from mysql and show on html

but I face
ModuleNotFoundError: No module named 'mysql'
Question:
  1. can HTML browser execute python module 'mysql'

  2. or if I keep execute .py script on WinSCP, can it run successfully without function lacking?

screenshot of error (model not found error).png

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum