Skip to content

[BUG] Using MySql with pyscript #381

@leothewolf

Description

@leothewolf

Describe the bug
I am not able to use mysql with pyscript!

To Reproduce
I have two files : index.html, a.py

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css"/>
</head>
<body>
</body>
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
<py-env>
    - mysql-connector-python
</py-env>
<py-script src="a.py"></py-script>
</html>

a.py

import mysql.connector as mb
conn = mb.connect(host="localhost",user="root",password="SAQQAR")
c = conn.cursor()
c.execute("use test")
c.execute("select * from test1")
f = c.fetchall()
print(f)

But it gives this error :

APPENDING: True ==> -6cece33c-98af-a521-8e0c-b342074d71ba --> PythonError: Traceback (most recent call last):
  File "/lib/python3.10/site-packages/_pyodide/_base.py", line 429, in eval_code
    .run(globals, locals)
  File "/lib/python3.10/site-packages/_pyodide/_base.py", line 300, in run
    coroutine = eval(self.code, globals, locals)
  File "<exec>", line 1, in <module>
  File "/lib/python3.10/site-packages/mysql/connector/__init__.py", line 53, in <module>
    from .connection import MySQLConnection
  File "/lib/python3.10/site-packages/mysql/connector/connection.py", line 44, in <module>
    from .constants import (
  File "/lib/python3.10/site-packages/mysql/connector/constants.py", line 32, in <module>
    import ssl
  File "/lib/python3.10/ssl.py", line 98, in <module>
    import _ssl             # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'

Expected behavior
It should print out : [('hello',), ('there',), ('how',), ('are',)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions