如何将带有 python 后端的 ReactJS 应用程序连接到 MySQL 数据库?

How i can connect my ReactJS App with python backend to MySQL database?

提问人:integoneo 提问时间:10/5/2023 更新时间:10/5/2023 访问量:29

问:

我需要什么才能将我的 python 服务器文件连接到 react 应用程序? 我设法将 python 文件连接到 SQL 数据库,我可以用 python 编写 MySQL quires,但我不知道如何将 python 文件链接到 react 应用程序

这是我 index.py:

from getpass import getpass
from mysql.connector import connect, Error
try:
    with connect(
        host="localhost",
        user="root",
        password= getpass(),
        database = "knowledges"
    ) as connection:
            show_articles = "SELECT * FROM articles"
        with connection.cursor() as cursor:
            cursor.execute(show_articles)
            for artcl in cursor:
                print(artcl)
            
except Error as e:
    print(e)

我可以在没有 Python 框架的情况下连接它们,还是可以使用纯 Python 语言?

python mysql reactjs mysql连接器-python

评论


答: 暂无答案