当前位置: 首页 > 工具软件 > demo-ureport > 使用案例 >

demo_utils

楚宪
2023-12-01
邮件utils


from smtplib import SMTP_SSL
from email.mime.text import MIMEText

smtp_host = "smtp.qq.com"
smtp_port = 465
smtp_username = "1546596867@qq.com"
smtp_password = "x"
# 初始化一个邮件服务器连接
smtp_server = SMTP_SSL(smtp_host, smtp_port)
# 登录
smtp_server.login(smtp_username, smtp_password)
# 初始化一个邮件对象
message = MIMEText("我是邮件内容")
message['subject'] = "我是邮件标题"
message['from'] = "帅哥"
message['to'] = "靓仔"
# 发送邮件
smtp_server.sendmail(smtp_username, ["1546596867@qq.com", "994740878@qq.com"], message.as_string())

sql utils

import pymysql

# 初始化数据库连接
conn = pymysql.connect(
    host="192.168.31.13",
    port=3306,
    user="root",
    password="Aa654321.",
    database="irc_21",
    charset="utf8"
)

# 获取游标
cursor = conn.cursor()
# 使用游标执行sql
cursor.execute("select * from irc;")
# 从游标中获取数据
# print(cursor.fetchone())
# print(cursor.fetchone())

print("--------------------")
print(cursor.fetchall())

# # 插入一条数据
# cursor.execute("insert into z_irc(name) values('zhaoliu');")
# cursor.execute("insert into z_irc(name) values('rongqi');")
#
# # 提交
# conn.commit()

 类似资料:

相关阅读

相关文章

相关问答