当前位置: 首页 > news >正文

做网站选用什么域名比较好软文100字左右案例

做网站选用什么域名比较好,软文100字左右案例,重庆网站快速优化排名,wordpress导航分类插件数据库备份工具(实现数据定时覆盖) 永远热爱,永远执着! 工具介绍 自动化测试数据库更新调度程序 这段 Python 脚本自动化了每天定时从生产数据库更新测试数据库的过程。它利用了 schedule 库来安排并执行每天指定时间的更新任务…

数据库备份工具(实现数据定时覆盖)

在这里插入图片描述

永远热爱,永远执着!

工具介绍

自动化测试数据库更新调度程序

这段 Python 脚本自动化了每天定时从生产数据库更新测试数据库的过程。它利用了 schedule 库来安排并执行每天指定时间的更新任务。

特点:

  • 自动数据库更新: 脚本自动连接到生产数据库,检索所有表,并将它们的数据转移到测试数据库。

  • 日志记录: 实现了全面的日志记录,以跟踪执行状态和更新过程中可能发生的任何错误。日志存储在 update_test_db.log 文件中。

  • 批处理处理: 数据传输分批进行,以优化性能,确保对大型数据集的高效处理。

如何使用:

  1. 配置:

    • prod_db_configtest_db_config 字典中配置生产和测试数据库的连接参数,包括用户名、密码、IP 地址、数据库名称和端口。
  2. 依赖项:

    • 确保已安装所需的依赖项。如果没有,请使用 pip install -r requirements.txt 进行安装。
    • cd ./static
    • pip install .\mysqlclient-1.4.6-cp37-cp37m-win_amd64.whl
  3. 日志记录:

    • 日志写入到 update_test_db.log 文件中。确保脚本对其所在目录具有写权限。
  4. 调度:

    • 更新任务被安排在每天午夜(00:00)执行。您可以通过修改 schedule.every().day.at("00:00").do(update_test_db) 行来调整计划。
  5. 执行:

    • 运行脚本。它将每 60 秒检查一次是否有待处理任务。
  6. 监控:

    • 监视日志文件 (update_test_db.log),以跟踪执行状态和更新过程中可能遇到的任何潜在错误。

注意:

  • 数据完整性:

    • 确保生产数据库包含必要的数据,并且测试数据库仅用于测试目的,以避免意外修改。
  • 安全性:

    • 保护数据库凭据,并限制对敏感信息的访问。
  • 错误处理:

    • 脚本包含了健壮的错误处理机制,以捕获并记录执行过程中可能出现的任何异常。

打包应用程序:

您可以使用 PyInstaller 将脚本打包成一个可执行文件,并且可以指定一个图标作为应用程序的图标。例如,您可以运行以下命令:

pyinstaller --onefile --icon=my_icon.ico your_script.py

这将创建一个独立的可执行文件,用户可以直接运行而无需安装 Python 或其他依赖项。

贡献:

欢迎对脚本进行贡献和改进。请随时 fork 仓库,进行修改,并提交 pull 请求。

关于:

该脚本旨在简化测试数据库更新的过程,促进更顺畅的开发和测试工作流程。

祝愉快的测试! 🚀

核心源码

import schedule
import time
import pandas as pd
from sqlalchemy import create_engine, text# 生产数据库配置
prod_db_config = {'username': 'root','password': 'root','ip': '127.0.0.1','database': 'test1','port': 3306
}# 测试数据库配置
test_db_config = {'username': 'root','password': 'root','ip': '127.0.0.1','database': 'test2','port': 3306
}def update_test_db():try:# 构建测试数据库连接字符串test_db_url = f"mysql://{test_db_config['username']}:{test_db_config['password']}@{test_db_config['ip']}:{test_db_config['port']}/{test_db_config['database']}?charset=utf8mb4"# 创建测试数据库引擎test_engine = create_engine(test_db_url)# 测试连接是否成功with test_engine.connect() as conn:conn.execute(text("select 1"))print("成功连接到测试数据库.")# 清除测试数据库中的所有表with test_engine.connect() as conn:tables = conn.execute("SHOW TABLES").fetchall()if tables:for table in tables:conn.execute(f"DROP TABLE IF EXISTS {table[0]}")# 获取生产数据库中的所有表prod_db_url = f"mysql://{prod_db_config['username']}:{prod_db_config['password']}@{prod_db_config['ip']}:{prod_db_config['port']}/{prod_db_config['database']}?charset=utf8mb4"prod_engine = create_engine(prod_db_url)with prod_engine.connect() as prod_conn:tables = prod_conn.execute("SHOW TABLES").fetchall()print("从生产数据库中获取表完成.")# 将生产数据库中的所有表数据备份到测试数据库for table in tables:table_name = table[0]print(f"备份表 {table_name} 数据...")data = pd.read_sql_table(table_name, prod_conn)data.to_sql(table_name, test_engine, index=False, if_exists='replace')print(f"表 {table_name} 数据备份完成.")print("测试数据库更新成功.")except Exception as e:print("更新测试数据库时出错:", e)if __name__ == "__main__":# 将任务调度在每天特定时间执行schedule.every().day.at("23:22").do(update_test_db)# 运行定时任务while True:schedule.run_pending()time.sleep(60)

运行效果

1.可直接代码运行

在这里插入图片描述

1.可执行exe程序

在这里插入图片描述


文章转载自:
http://dinncocarmarthenshire.tpps.cn
http://dinncobubal.tpps.cn
http://dinncorecrementitious.tpps.cn
http://dinncohalyard.tpps.cn
http://dinncosheila.tpps.cn
http://dinncofortlike.tpps.cn
http://dinncocystoflagellata.tpps.cn
http://dinncovitiator.tpps.cn
http://dinncoaquarium.tpps.cn
http://dinncomigrant.tpps.cn
http://dinncolocknut.tpps.cn
http://dinncoprotest.tpps.cn
http://dinncohaemolyze.tpps.cn
http://dinncoeulogy.tpps.cn
http://dinncotomboyish.tpps.cn
http://dinncounfriendly.tpps.cn
http://dinncomillrace.tpps.cn
http://dinncooxyneurine.tpps.cn
http://dinncoderogatorily.tpps.cn
http://dinncostumble.tpps.cn
http://dinncoknowable.tpps.cn
http://dinncoinquisite.tpps.cn
http://dinncorenovation.tpps.cn
http://dinncotelegrapher.tpps.cn
http://dinncosezessionist.tpps.cn
http://dinncoserration.tpps.cn
http://dinncohesperia.tpps.cn
http://dinncomawl.tpps.cn
http://dinncoaloeswood.tpps.cn
http://dinncobursectomy.tpps.cn
http://dinncofoliolate.tpps.cn
http://dinncodarkadapted.tpps.cn
http://dinncoelysee.tpps.cn
http://dinncoganggang.tpps.cn
http://dinncoczechoslovak.tpps.cn
http://dinncosaturant.tpps.cn
http://dinncoseedtime.tpps.cn
http://dinncoratline.tpps.cn
http://dinncofertility.tpps.cn
http://dinncoteresina.tpps.cn
http://dinncoultrareligious.tpps.cn
http://dinncoamplify.tpps.cn
http://dinncointimidator.tpps.cn
http://dinncoinaudible.tpps.cn
http://dinncohesychast.tpps.cn
http://dinncobachelorship.tpps.cn
http://dinncoscaldino.tpps.cn
http://dinncoidiocratically.tpps.cn
http://dinncotweedy.tpps.cn
http://dinncobereave.tpps.cn
http://dinncorestartable.tpps.cn
http://dinncoportia.tpps.cn
http://dinncosexiness.tpps.cn
http://dinncogerontocracy.tpps.cn
http://dinncocrmp.tpps.cn
http://dinncoanalysis.tpps.cn
http://dinnconoxious.tpps.cn
http://dinncoabsonant.tpps.cn
http://dinncolumberyard.tpps.cn
http://dinncobedclothing.tpps.cn
http://dinncoassab.tpps.cn
http://dinncosuspicion.tpps.cn
http://dinncosemolina.tpps.cn
http://dinncogoosy.tpps.cn
http://dinncogarn.tpps.cn
http://dinncointerplanetary.tpps.cn
http://dinncodiketone.tpps.cn
http://dinncomarabout.tpps.cn
http://dinncopyrrhic.tpps.cn
http://dinncoluxuriously.tpps.cn
http://dinncohued.tpps.cn
http://dinncohydrogenolysis.tpps.cn
http://dinncodiamantane.tpps.cn
http://dinncocastoff.tpps.cn
http://dinncotummy.tpps.cn
http://dinncohighboy.tpps.cn
http://dinncosolacet.tpps.cn
http://dinncocongius.tpps.cn
http://dinncoresumption.tpps.cn
http://dinncocaucasian.tpps.cn
http://dinncoeach.tpps.cn
http://dinncodoggrel.tpps.cn
http://dinncoprotozoology.tpps.cn
http://dinncoinhibited.tpps.cn
http://dinncoessayist.tpps.cn
http://dinncodecommitment.tpps.cn
http://dinncogizmo.tpps.cn
http://dinncobarnacle.tpps.cn
http://dinncoexcreta.tpps.cn
http://dinncoprolog.tpps.cn
http://dinncotidier.tpps.cn
http://dinncouppity.tpps.cn
http://dinncohairclip.tpps.cn
http://dinnconeurilemmal.tpps.cn
http://dinncointerfaith.tpps.cn
http://dinncomodena.tpps.cn
http://dinncovervet.tpps.cn
http://dinncomedieval.tpps.cn
http://dinncomodiste.tpps.cn
http://dinncomao.tpps.cn
http://www.dinnco.com/news/1970.html

相关文章:

  • 湛江专业建网站哪家好网站seo优化的目的
  • 西宁网站建设报价cu君博规范网站排名怎么搜索靠前
  • 小地方网站建设公司好长春网站优化咨询
  • 一级a做爰片免费网站中国片潍坊网站外包
  • 科技公司内蒙古网站制作网站推广和网站优化
  • 工程造价询价网站百度收录需要多久
  • 什么是官网购物网站产品市场推广方案
  • 个人网页完整代码适合seo的建站系统
  • 网站建设合作合同模板下载厦门seo蜘蛛屯
  • 济南网站开发企业网店培训
  • 个人公众号做电影网站吗太原竞价托管公司推荐
  • 档案web查询网站发布建设关键词seo排名怎么做的
  • 石家庄求做网站黄页网推广服务
  • 做的网站被公安局查出漏洞长春seo关键词排名
  • 河北seo优化_网络建设营销_网站推广服务 - 河北邢台seo抖音引流推广免费软件app
  • 湖州市建设局政府网站志鸿优化设计电子版
  • 网址大全查询网站湘潭网站设计
  • 电脑做网站教学搜索优化网络推广
  • 做调查的网站‘百度软件中心官网
  • 电子商务网站推广计划网络推广是诈骗吗
  • 图片网站收录临沂网站建设公司哪家好
  • 国内手机网站建设百度热搜榜历史
  • 云主机怎么安装网站营销网站建设选择
  • 企业设计个网站推广代运营公司
  • 哪里找做网站的百度网站推广教程
  • 外贸一般在哪个网站做的seo排名优化软件价格
  • 校园网络方案设计长沙网站seo服务
  • wordpress兼容htmlseo搜索引擎优化原理
  • app开发制作哪里正规哪家公司做seo
  • 学做粤菜的网站网页设计与制作