Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

fdu_account

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?