【MySQL数据库原理】Python3.7 中连接 MySQL 数据库

1、安装mysql-connector-python

要在 Python 中连接 MySQL 数据库 “test”,可以使用 “mysql-connector-python” 包。首先,确保已经安装了该包。可以使用 pip 命令进行安装:

pip install mysql-connector-python
或
pip install mysql-connector-python -i https://pypi.tuna.tsinghua.edu.cn/simple

在这里插入图片描述

2、连接 MySQL 数据库

一定要开启数据库,然后,在 Python 代码中,可以使用以下代码来连接数据库test:

import mysql.connector

猜你喜欢

转载自blog.csdn.net/weixin_41194129/article/details/130071386