thief_music_api/test/sql_test.py
Joe 3d73f1ad10
All checks were successful
continuous-integration/drone/push Build is passing
feat:新增fastapi-login,数据库表
2023-08-16 19:40:35 +08:00

24 lines
571 B
Python

# 导入pymysql
import pymysql
import untils
mysql_host = untils.mysql_host
mysql_port = untils.mysql_port
mysql_user = untils.mysql_user
mysql_password = untils.mysql_password
mysql_database = untils.mysql_database
# 创建连接
con = pymysql.connect(host=mysql_host, user=mysql_user, password=mysql_password,port=mysql_port, charset="utf8", database=mysql_database)
# 创建游标对象
cursor = con.cursor()
email = "1264204425@qq.com"
# 编写创建表的sql
cursor.execute("SELECT * FROM User WHERE email = %s", (email,))
user = cursor.fetchone()
print(user)