Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

(python) mysql.connector.errors.InterfaceError: 2003 #56

Open
jtoncrise00300 opened this issue Feb 1, 2023 · 0 comments
Open

(python) mysql.connector.errors.InterfaceError: 2003 #56

jtoncrise00300 opened this issue Feb 1, 2023 · 0 comments

Comments

@jtoncrise00300
Copy link

I write a .py script can extract mysql data and print it out, I want to make the html page run this script and face mysql.connector.errors.InterfaceError, but .py script individually works fine

environment: I put both .py and .html in winSCP to make the page live

  • get_sql_where.py (the script can execute fine by itself, I ran get_sql_where.py in cmd works fine )
import mysql.connector
import webbrowser
import time
import pymysql

mydb = mysql.connector.connect(
  host="196.168.1.141",
  user="root",
  password="password123", 
  database="normal_db",  
  auth_plugin='mysql_native_password'
)
              
mycursor = mydb.cursor()
mycursor.execute("SELECT P_TITLE,P_DESC  FROM webpage WHERE P_ID = 'en_1-01'")                       
                                         
myresult = mycursor.fetchall()

print(myresult)    
  • .html page
<!DOCTYPE html>
<!-- myPyScriptRun.html -->
<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>this is the info from sql</p></b><br>
    <py-config>
packages = ["mysql-connector-python", "PyMySQL"]
    </py-config>
    <py-script src="./get_sql_where.py" />
</body></html>

Main Problem: face mysql.connector.errors.InterfaceError: 2003

  • error message
Traceback (most recent call last):
  File "/lib/python3.10/site-packages/mysql/connector/network.py", line 600, in open_connection
    self.sock.connect(sockaddr)
BlockingIOError: [Errno 26] Operation in progress

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/lib/python3.10/site-packages/_pyodide/_base.py", line 435, in eval_code
    .run(globals, locals)
  File "/lib/python3.10/site-packages/_pyodide/_base.py", line 304, in run
    coroutine = eval(self.code, globals, locals)
  File "<exec>", line 9, in <module>
  File "/lib/python3.10/site-packages/mysql/connector/pooling.py", line 294, in connect
    return MySQLConnection(*args, **kwargs)
  File "/lib/python3.10/site-packages/mysql/connector/connection.py", line 167, in __init__
    self.connect(**kwargs)
  File "/lib/python3.10/site-packages/mysql/connector/abstracts.py", line 1178, in connect
    self._open_connection()
  File "/lib/python3.10/site-packages/mysql/connector/connection.py", line 571, in _open_connection
    self._socket.open_connection()
  File "/lib/python3.10/site-packages/mysql/connector/network.py", line 602, in open_connection
    raise InterfaceError(
mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on '196.168.1.141:3306' (26 Operation in progress)

I tried super hard to achieve this goal, hope someone can give a hand

I have read through link 01 , link 02 discussion but I don't find the fit solution for my case, thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant