1 Star 6 Fork 1

jflearn/Flask-COVID19

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ts.py 1.91 KB
一键复制 编辑 原始数据 按行查看 历史
jflearn 提交于 2022-06-28 10:34 . 第一次提交
# -*- coding: utf-8 -*-
# @Time : 2021/10/11 22:36
# @Author : JustFly
# @File : ts.py
# @Software : PyCharm
import requests
import json
import time
import pymysql
import traceback
from selenium import webdriver
def get_connphp():
"""
:return: 连接, 游标
"""
# 创建连接
conn = pymysql.connect(host="127.0.0.1",
user="root",
password="123456",
db="covid_2019",
)
# 创建游标
cursor = conn.cursor()
return conn, cursor
def get_conncts():
"""
:return: 连接, 游标
"""
# 创建连接
conn = pymysql.connect(host="1.15.49.8",
user="root",
password="jjf521zl!",
db="covid_2019",
)
# 创建游标
cursor = conn.cursor()
return conn, cursor
def close_conn(conn, cursor):
if cursor:
cursor.close()
if conn:
conn.close()
def querya(sql, *args):
"""
封装通用查询
:param sql:
:param args:
:return:元组
"""
conn, cursor = get_connphp()
cursor.execute(sql, args)
res = cursor.fetchall()
# print(res)
close_conn(conn, cursor)
return res
def queryb(sql, *args):
"""
封装通用查询
:param sql:
:param args:
:return:元组
"""
conn, cursor = get_conncts()
cursor.execute(sql, args)
res = cursor.fetchall()
# print(res)
close_conn(conn, cursor)
return res
conna, cursora = get_connphp()
connb, cursorb = get_conncts()
sqla = "select * from history"
data_a = querya(sqla)
for d in data_a:
sqlb = "insert into history(ds, confirm, confirm_add, suspect, suspect_add, heal, heal_add, dead, dead_add)" \
" values (%s, %s, %s, %s, %s, %s, %s, %s, %s)"
print(d[0])
cursorb.execute(sqlb, d)
connb.commit()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/jflearn/flask-covid19.git
git@gitee.com:jflearn/flask-covid19.git
jflearn
flask-covid19
Flask-COVID19
master

搜索帮助