Python操作sql,备份数据库

1、批量执行sql

import pymysql# 执行批量的 SQL 语句
def executeBatchSql(cursor, sqlStatements):for sql in sqlStatements:try:cursor.execute(sql)print('Executed SQL statement:', sql)except Exception as e:print('Error executing SQL statement:', e)# 创建数据库连接
connection = pymysql.connect(host='xx.xx.xx.xx',port=xx,user='root',password='xx',database='xx',autocommit=True  # 设置自动提交模式
)# 连接数据库
try:with connection.cursor() as cursor:print('Connected to database')# 执行批量的 SQL 语句sqlStatements = ["UPDATE conveyor_exception_time SET date = DATE_SUB(CURDATE(), INTERVAL 1 DAY); ","UPDATE detection_ng_analysis SET date = CURDATE(); ","UPDATE single_data_analysis SET date = CURDATE(); ","UPDATE area_data_analysis SET date = CURDATE(); ","UPDATE store_area SET status = FLOOR(RAND() * 8);",# "UPDATE area_data_analysis SET `date`=DATE_SUB(CURDATE(), INTERVAL 0 DAY);","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 1 DAY) WHERE id='17';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 1 DAY) WHERE id='18';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 1 DAY) WHERE id='19';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 1 DAY) WHERE id='20';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 2 DAY) WHERE id='21';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 2 DAY) WHERE id='22';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 2 DAY) WHERE id='23';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 2 DAY) WHERE id='24';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 3 DAY) WHERE id='25';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 3 DAY) WHERE id='26';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 3 DAY) WHERE id='27';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 3 DAY) WHERE id='28';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 4 DAY) WHERE id='5';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 4 DAY) WHERE id='6';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 4 DAY) WHERE id='7';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 4 DAY) WHERE id='8';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 5 DAY) WHERE id='13';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 5 DAY) WHERE id='14';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 5 DAY) WHERE id='15';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 5 DAY) WHERE id='16';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 6 DAY) WHERE id='9';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 6 DAY) WHERE id='10';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 6 DAY) WHERE id='11';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 6 DAY) WHERE id='12';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 7 DAY) WHERE id='1';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 7 DAY) WHERE id='2';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 7 DAY) WHERE id='3';","UPDATE stacker_analysis_history SET `date`=DATE_SUB(CURDATE(), INTERVAL 7 DAY) WHERE id='4';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 0 DAY) WHERE id='0493';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 0 DAY) WHERE id='04c5';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 0 DAY) WHERE id='07d3';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 0 DAY) WHERE id='0e75';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 1 DAY) WHERE id='2712';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 1 DAY) WHERE id='2bd0';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 1 DAY) WHERE id='2e5f';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 1 DAY) WHERE id='32e2';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 2 DAY) WHERE id='43b9';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 2 DAY) WHERE id='4476';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 2 DAY) WHERE id='4514';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 2 DAY) WHERE id='4bcb';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 3 DAY) WHERE id='5e97';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 3 DAY) WHERE id='6781';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 3 DAY) WHERE id='6ae8';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 3 DAY) WHERE id='81a8';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 4 DAY) WHERE id='8d4c';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 4 DAY) WHERE id='8e66';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 4 DAY) WHERE id='9c59';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 4 DAY) WHERE id='9f77';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 5 DAY) WHERE id='a771';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 5 DAY) WHERE id='a809';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 5 DAY) WHERE id='ad77';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 5 DAY) WHERE id='b560';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 6 DAY) WHERE id='be6f';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 6 DAY) WHERE id='c567';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 6 DAY) WHERE id='c8f0';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 6 DAY) WHERE id='cbec';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 7 DAY) WHERE id='d24d';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 7 DAY) WHERE id='d4e6';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 7 DAY) WHERE id='da7e';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 7 DAY) WHERE id='e627';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 0 DAY) WHERE id='022e';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 0 DAY) WHERE id='02a5';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 0 DAY) WHERE id='060a';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 0 DAY) WHERE id='1649';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 1 DAY) WHERE id='1888';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 1 DAY) WHERE id='1a1f';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 1 DAY) WHERE id='2c33';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 1 DAY) WHERE id='3f44';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 2 DAY) WHERE id='48b2';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 2 DAY) WHERE id='4c45';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 2 DAY) WHERE id='4ca3';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 2 DAY) WHERE id='6760';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 3 DAY) WHERE id='679d';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 3 DAY) WHERE id='7201';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 3 DAY) WHERE id='73cc';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 3 DAY) WHERE id='815c';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 4 DAY) WHERE id='894a';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 4 DAY) WHERE id='8a45';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 4 DAY) WHERE id='96fe';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 4 DAY) WHERE id='9843';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 5 DAY) WHERE id='a46e';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 5 DAY) WHERE id='a471';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 5 DAY) WHERE id='a552';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 5 DAY) WHERE id='b6af';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 6 DAY) WHERE id='c9cd';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 6 DAY) WHERE id='cf82';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 6 DAY) WHERE id='d201';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 6 DAY) WHERE id='daff';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 7 DAY) WHERE id='de2d';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 7 DAY) WHERE id='ec95';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 7 DAY) WHERE id='ee4c';","UPDATE `jeecg-boot`.area_data_analysis SET `date`= DATE_SUB(CURDATE(), INTERVAL 7 DAY) WHERE id='fe9b';",# "UPDATE area_data_analysis SET date = CURDATE() WHERE date = DATE_SUB(CURDATE(), INTERVAL 1 DAY);", # "UPDATE area_data_analysis SET date = DATE_SUB(CURDATE(), INTERVAL 1 DAY) WHERE date = DATE_SUB(CURDATE(), INTERVAL 2 DAY);", # "UPDATE area_data_analysis SET date = DATE_SUB(CURDATE(), INTERVAL 2 DAY) WHERE date = DATE_SUB(CURDATE(), INTERVAL 3 DAY);", # "UPDATE area_data_analysis SET date = DATE_SUB(CURDATE(), INTERVAL 3 DAY) WHERE date = DATE_SUB(CURDATE(), INTERVAL 4 DAY);", # "UPDATE area_data_analysis SET date = DATE_SUB(CURDATE(), INTERVAL 4 DAY) WHERE date = DATE_SUB(CURDATE(), INTERVAL 5 DAY);", # "UPDATE area_data_analysis SET date = DATE_SUB(CURDATE(), INTERVAL 5 DAY) WHERE date = DATE_SUB(CURDATE(), INTERVAL 6 DAY);", # "UPDATE area_data_analysis SET date = DATE_SUB(CURDATE(), INTERVAL 6 DAY) WHERE date = DATE_SUB(CURDATE(), INTERVAL 7 DAY);", # "UPDATE area_data_analysis SET date = DATE_SUB(CURDATE(), INTERVAL 7 DAY) WHERE date = DATE_SUB(CURDATE(), INTERVAL 8 DAY);", # "UPDATE area_data_analysis SET `date`=DATE_SUB(CURDATE(), INTERVAL 2 DAY) WHERE operation_code = 'OP03' AND  date = DATE_SUB(CURDATE(), INTERVAL 2 DAY);",# "",]executeBatchSql(cursor, sqlStatements)finally:# 关闭数据库连接connection.close()print("\033[32;44;1mSQL执行完成, Mock数据初始化完成...\033[0m")

2、备份数据库

import subprocessdef backup_mysql_database(host, port, user, password, database, output_file):# 构建备份命令command = f"mysqldump --host={host} --port={port} --user={user} --password={password} {database} > {output_file}"try:# 执行备份命令print("数据库备份进行中,请稍等...")subprocess.run(command, shell=True, check=True)print("数据库备份成功!")except subprocess.CalledProcessError as e:print(f"数据库备份失败:{e}")# 调用备份函数
host='xx.xx.xx.xx'
port=xx
user='root'
password='xx'
database='xx'
backup_mysql_database(host, port, user, password, database, "./data/jeecg-boot.sql")

3、使用shell执行python脚本

#!/bin/bash# 切换到Python脚本所在的目录# 执行Python脚本
python sql.py# 添加等待命令,不让脚本关闭
read -p "Press any key to exit..."

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/51668.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

AMBA总线协议(0)——目录与传送门

一、AMBA总线协议 Arm高级微控制器总线架构(Advanced Microcontroller Bus Architecture,AMBA)是一种开放式标准片上互联规范,用于连接和管理片上系统(System on Chip,Soc)中的功能块。 AMBA是一种广泛用于…

设计模式-代理模式

代理模式 ● 为对象提供一个代理类,增强该对象的方法,控制对这个对象的访问 ● 静态代理和动态代理:静态代理就是编译的时候就已经确定,而动态代理就是运行时才会生成 静态代理的使用场景 缓存代理 ● 提供数据的缓存功能&…

python字符串处理15题-刷题

题目一:最长无重复子串长度 给定一个字符串,找出其中不含有重复字符的最长子串的长度。 示例: 输入: "abcabcbb" 输出: 3 解释: 最长无重复子串是 "abc",长度为 3。 解答: def length_of_longest…

Ubuntu vi 左下角没有提示

1 打开终端,输入以下命令 sudo gedit /etc/vim/vimrc.tiny 2 进入文件后,修改 set compatible 为set nocompatible,如下所示: " Vim configuration file, in effect when invoked as "vi". The aim of this "…

全球公链进展| Shibarium已上线;opBNB测试网PreContract硬分叉;Sui 主网 V1.7.1 版本

01 ETH 以太坊最新一次核心开发者执行会议:讨论 Devnet 8 更新、ElP-4788、Holesky 测试网等 以太坊核心开发者 Tim Beiko 总结最新一次以太坊核心开发者执行会议(ACDE),讨论内容包括 Devnet 8 更新、ElP-4788、Holesky 测试网、…

【DevOps视频笔记】4.Build 阶段 - Maven安装配置

一、Build 阶段工具 二、Operate阶段工具 三、服务器中安装 四、修改网卡信息 五、安装 jdk 和 maven Stage1 : 安装 JDK Stage 2 : 安装 Maven 2-1 : 更换文件夹名称 2-2 : 替换配置文件 settings.xml- 2-3 : 修改settings.xml详情 A. 修改maven仓库地址 - 阿里云 B…

CentOS系统环境搭建(十七)——elasticsearch设置密码

centos系统环境搭建专栏🔗点击跳转 elasticsearch设置密码 没有密码是很不安全的一件事😭 文章目录 elasticsearch设置密码1.设置密码2.登录elasticsearch3.登录kibana4.登录elasticsearch-head 1.设置密码 关于Elasticsearch的安装请看CentOS系统环境搭…

适配小程序隐私保护指引设置

由于小程序发布了一个公告,那么接下来就是怎么改简单的问题了。毕竟不太想大的改动历史上的代码。尽量简单的适配隐私策略就可以了。 整体思路也是参考现在App普遍的启动就让用户同意隐私策略,不同意不让用,同意了之后才能够继续使用。 公告…

ubuntu下mysql

安装: sudo apt update sudo apt install my_sql 安装客户端: sudo apt-get install mysql-client sudo apt-get install libmysqlclient-dev 启动服务 启动方式之一: sudo service mysql start 检查服务器状态方式之一:sudo …

计算机网络 QA

DNS 的解析过程 浏览器缓存。当用户通过浏览器访问某域名时,浏览器首先会在自己的缓存中查找是否有该域名对应的 IP 地址(曾经访问过该域名并且没有清空缓存)系统缓存。当浏览器缓存中无域名对应的 IP 地址时,会自动检测用户计算机…

在WPF Visual Tree中查找父控件

实现 private static T FindVisualParent<T>(DependencyObject child)where T : DependencyObject{DependencyObject parentObject VisualTreeHelper.GetParent(child);if (parentObject null){return null;}T parent parentObject as T;if (parent ! null){return pa…

软件测试技术之可用性测试之WhatsApp Web

Tag&#xff1a;可行性测试、测试流程、结果分析、案例分析 WhatsApp是一款面向智能手机的网络通讯服务&#xff0c;它可以通过网络传送短信、图片、音频和视频。WhatsApp在全球范围内被广泛使用&#xff0c;是最受欢迎的即时聊天软件。 虽然&#xff0c;在电脑上使用WhatsAp…

docker搭建owncloud,Harbor,构建镜像

1、使用mysql:5.6和 owncloud 镜像&#xff0c;构建一个个人网盘。 拉取镜像 docker pull owncloud docker pull mysql:5.6 2、安装搭建私有仓库 Harbor 1.下载docker-compose 2.安装harbor 3.编辑 harbor.yml文件 使用./intall.sh安装 4.登录 3、编写Dockerfile制作Web应用系…

【学习FreeRTOS】第13章——FreeRTOS队列

1.队列简介 队列是任务到任务、任务到中断、中断到任务数据交流的一种机制&#xff08;消息传递&#xff09; FreeRTOS基于队列&#xff0c; 实现了多种功能&#xff0c;其中包括队列集、互斥信号量、计数型信号量、二值信号量、 递归互斥信号量&#xff0c;因此很有必要深入了…

奇葩的this与$emit传值

需求&#xff1a;最近遇到了一个需求&#xff0c;把一个页面内部的tab选项卡改为路由控制的页面 问题&#xff1a;查询条件单独封装一个组件后给父组件页面通过$emit事件传递表单参数&#xff1b;但是在父组件中每次得到的表单值都是undefined&#xff1b;调试了半天&#xff0…

Linux CentOS7系统,抓取http协议的数据包

使用 tcpdump 命令 1.首先确认是否安装 [rootlocalhost ~]# which tcpdump /usr/bin/which: no tcpdump in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin) [rootlocalhost ~]#我这里没有安装 1.1 安装 tcpdump yum install tcpdump 安装成功如下&#xf…

设计模式 07 桥接模式

桥接模式&#xff08;Bridge Pattern&#xff09;属于结构型模式 概述 桥接模式是将抽象部分与它的实现部分分离&#xff0c;使它们都可以独立地变化。它是一种对象结构型模式&#xff0c;又称为柄体&#xff08;Handle and Body&#xff09;模式或接口&#xff08;Interface&…

一生一芯6——ubuntu rpm软件安装

ubuntu不支持rpm&#xff0c;需要将rpm软件安装包转成deb进行安装 安装alien sudo apt-get install alien格式转换 sudo alien xxx.rpm 在目录下会生成deb的安装包 软件安装 sudo dpkg -i xxx_amd64.deb 安装完成

【C++ 学习 ⑯】- 继承(上)

目录 一、继承的概念和定义 1.1 - 概念 1.2 - 定义 二、继承时的对象内存模型 三、向上转型和向下转型 四、继承时的名字遮蔽问题 4.1 - 有成员变量遮蔽时的内存分布 4.2 - 重名的基类成员函数和派生类成员函数不构成重载 一、继承的概念和定义 1.1 - 概念 C 中的继承…

(五)、Redisson锁机制源码分析

1、了解分布式锁的特性 1、锁的互斥性 也就是说,在任意时刻,只能有一个客户端能获取到锁,不能同时有两个或多个客户端获取到锁。简单来说,就比如上厕所,一个厕所只有一个坑位,只能一个人上,不能同时两个人或多个人上。2、锁的同一性 也就是说,锁只能被持有该锁的客户端…