mysql的json处理

写在前面

需要注意,5.7以上版本才支持,但如果是生产环境需要使用的话,尽量使用8.0版本,因为8.0版本对json处理做了比较大的性能优化。你你可以使用select version();来查看版本信息。

本文看下MySQL的json处理。在正式开始让我们先来准备一些测试数据:

CREATE TABLE `dept` (`id` int(11) NOT NULL,`dept` varchar(255) DEFAULT NULL,`json_value` json DEFAULT NULL,PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;insert into dept VALUES(1,'部门1','{"deptName": "部门1", "deptId": "1", "deptLeaderId": "3"}');
insert into dept VALUES(2,'部门2','{"deptName": "部门2", "deptId": "2", "deptLeaderId": "4"}');
insert into dept VALUES(3,'部门3','{"deptName": "部门3", "deptId": "3", "deptLeaderId": "5"}');
insert into dept VALUES(4,'部门4','{"deptName": "部门4", "deptId": "4", "deptLeaderId": "5"}');
insert into dept VALUES(5,'部门5','{"deptName": "部门5", "deptId": "5", "deptLeaderId": "5"}');

1:json字段名->’$.json属性’

通过json字段名->’$.json属性’语法格式可以访问到json中某个key的值,以如下查询方式看下。

1.1:用在DQL查询结果中

mysql> select id,json_value->'$.deptLeaderId' from dept where id=2;
+----+------------------------------+
| id | json_value->'$.deptLeaderId' |
+----+------------------------------+
|  2 | "4"                          |
+----+------------------------------+
1 row in set (0.01 sec)

1.2:用在DQL条件中

  • 单条件
mysql> select id from dept where json_value->'$.deptLeaderId'='4';
+----+
| id |
+----+
|  2 |
+----+
1 row in set (0.01 sec)
  • 和普通字段组合查询
mysql> select id from dept where json_value->'$.deptLeaderId'='4' and id>1;
+----+
| id |
+----+
|  2 |
+----+
1 row in set (0.01 sec)
  • json多条件
mysql> select id from dept where json_value->'$.deptLeaderId'='4' and json_value->'$.deptName' like '%部门%';
+----+
| id |
+----+
|  2 |
+----+
1 row in set (0.00 sec)

1.3:用在DQL关联查询中

先准备数据:

CREATE TABLE `dept_leader` (`id` int(11) NOT NULL,`leaderName` varchar(255) DEFAULT NULL,`json_value` json DEFAULT NULL,PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;insert into dept_leader VALUES(1,'leader1','{"name": "王一", "id": "1", "leaderId": "1"}');
insert into dept_leader VALUES(2,'leader2','{"name": "王二", "id": "2", "leaderId": "3"}');
insert into dept_leader VALUES(3,'leader3','{"name": "王三", "id": "3", "leaderId": "4"}');
insert into dept_leader VALUES(4,'leader4','{"name": "王四", "id": "4", "leaderId": "5"}');
insert into dept_leader VALUES(5,'leader5','{"name": "王五", "id": "5", "leaderId": "5"}');
  • 关联查询
mysql> SELECT dept.id,dept_leader.id from dept,dept_leader WHERE dept.json_value->'$.deptLeaderId'=dept_leader.json_value->'$.id' ;
+----+----+
| id | id |
+----+----+
|  1 |  3 |
|  2 |  4 |
|  3 |  5 |
|  4 |  5 |
|  5 |  5 |
|  6 |  5 |
|  7 |  5 |
|  8 |  5 |
+----+----+
8 rows in set (0.00 sec)

2:json_extract

语法格式json_extract(字段名,$.json字段名),用来从json字段中提取值,如下:

mysql> select id,json_extract(json_value,'$.deptName') as deptName from dept;
+----+------------------------------+
| id | deptName                     |
+----+------------------------------+
|  1 | "部门1"                      |
...mysql> SELECT * FROM dept WHERE JSON_EXTRACT(json_value,'$.deptName') like '%部门%'\G
*************************** 1. row ***************************id: 1dept: 部门1
json_value: {"deptId": "1", "deptName": "部门1", "deptLeaderId": "3"}
*************************** 2. row ***************************id: 2dept: 部门2
json_value: {"deptId": "2", "newData": "新增的数据", "deptName": "新增的部门1111", "deptLeaderId": "4"}
...cx 

3:JSON_OBJECT()

语法格式JSON_OBJECT(k,v[,k,v]),用来转换指定数据为json object,如下:

mysql> select json_object("name", "张三", "age", 99);
+------------------------------------------+
| json_object("name", "张三", "age", 99)   |
+------------------------------------------+
| {"age": 99, "name": "张三"}              |
+------------------------------------------+
1 row in set (0.01 sec)

4:JSON_CONTAINS()

语法JSON_CONTAINS(target, candidate[, path]),用来判断json格式中是否包含指定子对象,其中子对象需要通过json_object()生成,如下:

mysql> select * from dept WHERE JSON_CONTAINS(json_value, JSON_OBJECT("deptName","部门5"))-> ;
+----+---------+-------------------------------------------------------------+
| id | dept    | json_value                                                  |
+----+---------+-------------------------------------------------------------+
|  5 | 部门5   | {"deptId": "5", "deptName": "部门5", "deptLeaderId": "5"}   |
+----+---------+-------------------------------------------------------------+
1 row in set (0.01 sec)

注意需要使用json_object转换为object。

添加如下数据,看一个嵌套json对象的例子:

insert into dept VALUES(6,'部门9','{"deptName": {"dept":"de","depp":"dd"}, "deptId": "5", "deptLeaderId": "5"}');

判断嵌套对象是否存在:

mysql> SELECT * from dept WHERE JSON_CONTAINS(json_value->'$.deptName',JSON_OBJECT("depp","dd"));
+----+---------+--------------------------------------------------------------------------------+
| id | dept    | json_value                                                                     |
+----+---------+--------------------------------------------------------------------------------+
|  6 | 部门9   | {"deptId": "5", "deptName": {"depp": "dd", "dept": "de"}, "deptLeaderId": "5"} |
+----+---------+--------------------------------------------------------------------------------+
1 row in set (0.00 sec)mysql> SELECT * from ( SELECT *,json_value->'$.deptName' as deptName FROM dept ) t WHERE JSON_CONTAINS(deptName,JSON_OBJECT("depp","dd"));
...

5:JSON_ARRAY()

创建json数组,如下:

mysql> select json_array("pingpong","羽毛球","篮球");
+---------------------------------------------+
| json_array("pingpong","羽毛球","篮球")      |
+---------------------------------------------+
| ["pingpong", "羽毛球", "篮球"]              |
+---------------------------------------------+mysql> select json_array(json_object("name", "张三"), "篮球", json_object("name", "李四"));
+------------------------------------------------------------------------------------+
| json_array(json_object("name", "张三"), "篮球", json_object("name", "李四"))       |
+------------------------------------------------------------------------------------+
| [{"name": "张三"}, "篮球", {"name": "李四"}]                                       |
+------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

json格式化看下:
在这里插入图片描述

5.1:判断数组是否是否包含某子数组

准备数据:

insert into dept VALUES(7,'部门9','{"deptName": ["1","2","3"], "deptId": "5", "deptLeaderId": "5"}');
insert into dept VALUES(7,'部门9','{"deptName": ["5","6","7"], "deptId": "5", "deptLeaderId": "5"}');mysql> SELECT * from dept WHERE JSON_CONTAINS(json_value->'$.deptName',JSON_ARRAY("1"));
+----+---------+-------------------------------------------------------------------+
| id | dept    | json_value                                                        |
+----+---------+-------------------------------------------------------------------+
|  7 | 部门9   | {"deptId": "5", "deptName": ["1", "2", "3"], "deptLeaderId": "5"} |
+----+---------+-------------------------------------------------------------------+
1 row in set (0.05 sec)

6:JSON_TYPE()

获取类型:

mysql> SELECT json_value->'$.deptName' ,JSON_TYPE(json_value->'$.deptName') as type from dept;  
+------------------------------+--------+
| json_value->'$.deptName'     | type   |
+------------------------------+--------+
| "部门1"                      | STRING |
| "新增的部门1111"             | STRING |
| "部门3"                      | STRING |
| "部门4"                      | STRING |
| "部门5"                      | STRING |
| {"depp": "dd", "dept": "de"} | OBJECT |
| ["1", "2", "3"]              | ARRAY  |
| ["5", "6", "7"]              | ARRAY  |
+------------------------------+--------+

7:JSON_KEYS()

获取文档中所有的key,如下:

mysql> SELECT JSON_KEYS(json_value),json_value FROM dept where id=2\G
*************************** 1. row ***************************
JSON_KEYS(json_value): ["deptId", "newData", "deptName", "deptLeaderId"]json_value: {"deptId": "2", "newData": "新增的数据", "deptName": "新增的部门1111", "deptLeaderId": "4"}
1 row in set (0.01 sec)

8:JSON_SET()

更新或者是添加kv,无责插入,有则更新,语法格式JSON_SET(json_doc, path, val[, path, val] …),如下:

  • key存在时更新
mysql> select * from dept where id=1;
+----+---------+-------------------------------------------------------------+
| id | dept    | json_value                                                  |
+----+---------+-------------------------------------------------------------+
|  1 | 部门1   | {"deptId": "1", "deptName": "部门1", "deptLeaderId": "3"}   |
+----+---------+-------------------------------------------------------------+
1 row in set (0.00 sec)mysql> update dept set json_value=JSON_SET(json_value, '$.deptName', '部门1_更新后') where id=1;
Query OK, 1 row affected (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 0mysql> select * from dept where id=1;
+----+---------+-----------------------------------------------------------------------+
| id | dept    | json_value                                                            |
+----+---------+-----------------------------------------------------------------------+
|  1 | 部门1   | {"deptId": "1", "deptName": "部门1_更新后", "deptLeaderId": "3"}      |
+----+---------+-----------------------------------------------------------------------+
1 row in set (0.00 sec)
  • key不存在时插入
mysql> select * from dept where id=1;
+----+---------+-----------------------------------------------------------------------+
| id | dept    | json_value                                                            |
+----+---------+-----------------------------------------------------------------------+
|  1 | 部门1   | {"deptId": "1", "deptName": "部门1_更新后", "deptLeaderId": "3"}      |
+----+---------+-----------------------------------------------------------------------+
1 row in set (0.00 sec)mysql> update dept set json_value=JSON_SET(json_value, '$.deptAddr', '赢创动力4楼') where id=1;
Query OK, 1 row affected (0.03 sec)
Rows matched: 1  Changed: 1  Warnings: 0mysql> select * from dept where id=1;
+----+---------+-------------------------------------------------------------------------------------------------------+
| id | dept    | json_value                                                                                            |
+----+---------+-------------------------------------------------------------------------------------------------------+
|  1 | 部门1   | {"deptId": "1", "deptAddr": "赢创动力4楼", "deptName": "部门1_更新后", "deptLeaderId": "3"}           |
+----+---------+-------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
  • 一个key不存在,一个key存在
mysql> select * from dept where id=1;
+----+---------+-------------------------------------------------------------------------------------------------------+
| id | dept    | json_value                                                                                            |
+----+---------+-------------------------------------------------------------------------------------------------------+
|  1 | 部门1   | {"deptId": "1", "deptAddr": "赢创动力4楼", "deptName": "部门1_更新后", "deptLeaderId": "3"}           |
+----+---------+-------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)mysql> update dept set json_value=JSON_SET(json_value, '$.deptAddr', '八维学院', '$.newKey', 'newKey的value') where id=1;
Query OK, 1 row affected (0.04 sec)
Rows matched: 1  Changed: 1  Warnings: 0mysql> select * from dept where id=1;                                                                      +----+---------+-------------------------------------------------------------------------------------------------------------------------------+
| id | dept    | json_value                                                                                                                    |
+----+---------+-------------------------------------------------------------------------------------------------------------------------------+
|  1 | 部门1   | {"deptId": "1", "newKey": "newKey的value", "deptAddr": "八维学院", "deptName": "部门1_更新后", "deptLeaderId": "3"}           |
+----+---------+-------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

9:JSON_INSERT()

语法格式JSON_INSERT(json_doc, path, val[, path, val] …),插入文档,当值已经存在时忽略,如下:

mysql> select * from dept where id=2;
+----+---------+-------------------------------------------------------------+
| id | dept    | json_value                                                  |
+----+---------+-------------------------------------------------------------+
|  2 | 部门2   | {"deptId": "2", "deptName": "部门2", "deptLeaderId": "4"}   |
+----+---------+-------------------------------------------------------------+
1 row in set (0.01 sec)mysql> update dept set json_value=JSON_INSERT(json_value, '$.deptId', '已存在不更新', '$.addr', '西二旗') where id=2;
Query OK, 1 row affected (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 0mysql> select * from dept where id=2;                                                                      +----+---------+----------------------------------------------------------------------------------+
| id | dept    | json_value                                                                       |
+----+---------+----------------------------------------------------------------------------------+
|  2 | 部门2   | {"addr": "西二旗", "deptId": "2", "deptName": "部门2", "deptLeaderId": "4"}      |
+----+---------+----------------------------------------------------------------------------------+
1 row in set (0.00 sec)

10:JSON_REPLACE()

语法格式JSON_REPLACE(json_doc, path, val[, path, val] …),更新而不新增文档,如下:

mysql> update dept set json_value=JSON_REPLACE(json_value, '$.deptName', '部门2_新名称', '$.notExitsKey', '不会替换,因为不存在') where id=2;
Query OK, 1 row affected (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 0
mysql> select * from dept where id=2;                                                                      +----+---------+--------------------------------------------------------------------------------------------+
| id | dept    | json_value                                                                                 |
+----+---------+--------------------------------------------------------------------------------------------+
|  2 | 部门2   | {"addr": "西二旗", "deptId": "2", "deptName": "部门2_新名称", "deptLeaderId": "4"}         |
+----+---------+--------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

11:JSON_REMOVE()

语法格式JSON_REMOVE(json_doc, path[, path] …),删除文档:

mysql> select * from dept where id=3;
+----+---------+-------------------------------------------------------------+
| id | dept    | json_value                                                  |
+----+---------+-------------------------------------------------------------+
|  3 | 部门3   | {"deptId": "3", "deptName": "部门3", "deptLeaderId": "5"}   |
+----+---------+-------------------------------------------------------------+
1 row in set (0.00 sec)mysql> update dept set json_value=JSON_REMOVE(json_value, '$.depeName', '$.deptLeaderId') where id=3;
Query OK, 1 row affected (0.04 sec)
Rows matched: 1  Changed: 1  Warnings: 0mysql> select * from dept where id=3;
+----+---------+----------------------------------------+
| id | dept    | json_value                             |
+----+---------+----------------------------------------+
|  3 | 部门3   | {"deptId": "3", "deptName": "部门3"}   |
+----+---------+----------------------------------------+
1 row in set (0.00 sec)

12:JSON_SEARCH

在这里插入图片描述
语法格式JSON_SEARCH(json_doc,one_or_all,search_str [,escape_char [,path] ...]),
获取指定文档出现的位置,如果没有则返回NULL。

12.1:官方例子

  • 准备数据
mysql> SET @j = '["abc", [{"k": "10"}, "def"], {"x":"abc"}, {"y":"bcd"}]';
Query OK, 0 rows affected (0.00 sec)mysql> select @j;
+---------------------------------------------------------+
| @j                                                      |
+---------------------------------------------------------+
| ["abc", [{"k": "10"}, "def"], {"x":"abc"}, {"y":"bcd"}] |
+---------------------------------------------------------+
1 row in set (0.01 sec)
  • 查询
mysql> SELECT JSON_SEARCH(@j, 'one', 'abc'); // 第二参数查询终止条件,设置为one,即只查询一个
+-------------------------------+
| JSON_SEARCH(@j, 'one', 'abc') |
+-------------------------------+
| "$[0]"                        |
+-------------------------------+
1 row in set (0.01 sec)mysql> SELECT JSON_SEARCH(@j, 'all', 'abc'); // 第二个参数查询终止条件,设置为all,即查询所有匹配的
+-------------------------------+
| JSON_SEARCH(@j, 'all', 'abc') |
+-------------------------------+
| ["$[0]", "$[2].x"]            |
+-------------------------------+
1 row in set (0.01 sec)mysql> SELECT JSON_SEARCH(@j, 'all', 'ghi'); // 全局匹配不存在的,会返回NULL
+-------------------------------+
| JSON_SEARCH(@j, 'all', 'ghi') |
+-------------------------------+
| NULL                          |
+-------------------------------+
1 row in set (0.00 sec)mysql> SELECT JSON_SEARCH(@j, 'all', '10'); // 全局匹配10,返回具体位置的具体key
+------------------------------+
| JSON_SEARCH(@j, 'all', '10') |
+------------------------------+
| "$[1][0].k"                  |
+------------------------------+
1 row in set (0.01 sec)
  • 指定路径搜索
mysql> SELECT JSON_SEARCH(@j, 'all', '10', NULL, '$');
+-----------------------------------------+
| JSON_SEARCH(@j, 'all', '10', NULL, '$') |
+-----------------------------------------+
| "$[1][0].k"                             |
+-----------------------------------------+mysql> SELECT JSON_SEARCH(@j, 'all', '10', NULL, '$[*]');
+--------------------------------------------+
| JSON_SEARCH(@j, 'all', '10', NULL, '$[*]') |
+--------------------------------------------+
| "$[1][0].k"                                |
+--------------------------------------------+mysql> SELECT JSON_SEARCH(@j, 'all', '10', NULL, '$**.k');
+---------------------------------------------+
| JSON_SEARCH(@j, 'all', '10', NULL, '$**.k') |
+---------------------------------------------+
| "$[1][0].k"                                 |
+---------------------------------------------+mysql> SELECT JSON_SEARCH(@j, 'all', '10', NULL, '$[*][0].k');
+-------------------------------------------------+
| JSON_SEARCH(@j, 'all', '10', NULL, '$[*][0].k') |
+-------------------------------------------------+
| "$[1][0].k"                                     |
+-------------------------------------------------+mysql> SELECT JSON_SEARCH(@j, 'all', '10', NULL, '$[1]');
+--------------------------------------------+
| JSON_SEARCH(@j, 'all', '10', NULL, '$[1]') |
+--------------------------------------------+
| "$[1][0].k"                                |
+--------------------------------------------+#指定搜索路径为数组中第二个元素内的第一个元素
mysql> SELECT JSON_SEARCH(@j, 'all', '10', NULL, '$[1][0]');
+-----------------------------------------------+
| JSON_SEARCH(@j, 'all', '10', NULL, '$[1][0]') |
+-----------------------------------------------+
| "$[1][0].k"                                   |
+-----------------------------------------------+mysql> SELECT JSON_SEARCH(@j, 'all', 'abc', NULL, '$[2]');
+---------------------------------------------+
| JSON_SEARCH(@j, 'all', 'abc', NULL, '$[2]') |
+---------------------------------------------+
| "$[2].x"                                    |
+---------------------------------------------+
  • 模糊匹配
mysql> SELECT JSON_SEARCH(@j, 'all', '%a%');
+-------------------------------+
| JSON_SEARCH(@j, 'all', '%a%') |
+-------------------------------+
| ["$[0]", "$[2].x"]            |
+-------------------------------+mysql> SELECT JSON_SEARCH(@j, 'all', '%b%');
+-------------------------------+
| JSON_SEARCH(@j, 'all', '%b%') |
+-------------------------------+
| ["$[0]", "$[2].x", "$[3].y"]  |
+-------------------------------+# 指定搜索路径,$[0] = "abc"
mysql> SELECT JSON_SEARCH(@j, 'all', '%b%', NULL, '$[0]');
+---------------------------------------------+
| JSON_SEARCH(@j, 'all', '%b%', NULL, '$[0]') |
+---------------------------------------------+
| "$[0]"                                      |
+---------------------------------------------+# $[2] = {"x":"abc"}
mysql> SELECT JSON_SEARCH(@j, 'all', '%b%', NULL, '$[2]');
+---------------------------------------------+
| JSON_SEARCH(@j, 'all', '%b%', NULL, '$[2]') |
+---------------------------------------------+
| "$[2].x"                                    |
+---------------------------------------------+# $[1] = [{"k": "10"}, "def"] 模糊匹配无结果
mysql> SELECT JSON_SEARCH(@j, 'all', '%b%', NULL, '$[1]');
+---------------------------------------------+
| JSON_SEARCH(@j, 'all', '%b%', NULL, '$[1]') |
+---------------------------------------------+
| NULL                                        |
+---------------------------------------------+mysql> SELECT JSON_SEARCH(@j, 'all', '%b%', '', '$[1]');
+-------------------------------------------+
| JSON_SEARCH(@j, 'all', '%b%', '', '$[1]') |
+-------------------------------------------+
| NULL                                      |
+-------------------------------------------+mysql> SELECT JSON_SEARCH(@j, 'all', '%b%', '', '$[3]');
+-------------------------------------------+
| JSON_SEARCH(@j, 'all', '%b%', '', '$[3]') |
+-------------------------------------------+
| "$[3].y"                                  |
+-------------------------------------------+

12.2:实际例子

在日常开发过程中如果需要使用JSON_SEARCH查询的话,需要搭配IS NOT NULL来获取符合条件的数据,如果是返回是NULL则说明不存在,反之存在,所以,对于返回的具体位置信息我们一般是使用不到的,准备数据如下:

Create Table: CREATE TABLE `user` (`id` int(11) unsigned NOT NULL AUTO_INCREMENT,`name` varchar(64) NOT NULL COMMENT '名字',`age` int(4) unsigned NOT NULL COMMENT '年龄',`info` text COMMENT '补充信息',PRIMARY KEY (`id`),UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户表'INSERT INTO `user` (`name`, `age`, `info`) VALUES ('suhw', '23', '{"phone":"12312123434","language":["c++","java","go"]}');
INSERT INTO `user` (`name`, `age`, `info`) VALUES ('bob', '20', '{"phone":"18912123434","language":["c++","c","go","php"]}');

查询会java和go语言的数据:

mysql> select * from user where json_search(info, 'all', 'go') is not null and json_search(info, 'all', 'java') is not null;
+----+------+-----+--------------------------------------------------------+
| id | name | age | info                                                   |
+----+------+-----+--------------------------------------------------------+
|  1 | suhw |  23 | {"phone":"12312123434","language":["c++","java","go"]} |
+----+------+-----+--------------------------------------------------------+
1 row in set (0.00 sec)

写在后面

参考文章列表

【MySQL】对JSON数据操作(全网最全) 。

MySQL - json_search 小结 。

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

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

相关文章

PostgreSQL数据库中,查询时提示表不存在的解决办法

最近遇到一个奇怪的问题,以前从来没有遇到过,在postgres SCHEMA下执行select * from table1语句时,提示表不存在,而实际这个表确是存在的,只不过是在public SCHEMA下。在public SCHEMA下执行这个sql语句是没有问题的。…

【Linux下6818开发板(ARM)】在液晶屏上显示RGB颜色和BMP图片

(꒪ꇴ꒪ ),hello我是祐言博客主页:C语言基础,Linux基础,软件配置领域博主🌍快上🚘,一起学习!送给读者的一句鸡汤🤔:集中起来的意志可以击穿顽石!作者水平很有限,如果发现错误&#x…

C++ 类和对象

面向过程/面向对象 C语言是面向过程,关注过程,分析出求解问题的步骤,通过函数调用逐步解决问题 C是基于面对对象的,关注的是对象——将一件事拆分成不同的对象,依靠对象之间的交互完成 引入 C语言中结构体只能定义…

flask处理表单数据

flask处理表单数据 处理表单数据在任何 web 应用开发中都是一个常见的需求。在 Flask 中,你可以使用 request 对象来获取通过 HTTP 请求发送的数据。对于 POST 请求,可以通过 request.form 访问表单数据。例如: from flask import Flask, r…

IDEA中连接虚拟机 管理Docker

IDEA中连接虚拟机 管理Docker 📔 千寻简笔记介绍 千寻简笔记已开源,Gitee与GitHub搜索chihiro-notes,包含笔记源文件.md,以及PDF版本方便阅读,且是用了精美主题,阅读体验更佳,如果文章对你有帮…

【点云处理教程】00计算机视觉的Open3D简介

一、说明 Open3D 是一个开源库,使开发人员能够处理 3D 数据。它提供了一组用于 3D 数据处理、可视化和机器学习任务的工具。该库支持各种数据格式,例如 .ply、.obj、.stl 和 .xyz,并允许用户创建自定义数据结构并在程序中访问它们。 Open3D 广…

KafKa脚本操作

所有操作位于/usr/local/kafka_2.12-3.5.1/bin。 rootubuntu2203:/usr/local/kafka_2.12-3.5.1/bin# pwd /usr/local/kafka_2.12-3.5.1/bin rootubuntu2203:/usr/local/kafka_2.12-3.5.1/bin# ls connect-distributed.sh kafka-delegation-tokens.sh kafka-mirror-mak…

15. Spring AOP 的实现原理 代理模式

目录 1. 代理模式 2. 静态代理 3. 动态代理 3.1 JDK 动态代理 3.2 CGLIB 动态代理 4. JDK 动态代理和 CGLIB 动态代理对比 5. Spring代理选择 6. Spring AOP 实现原理 6.1 织入 7. JDK 动态代理实现 8. CGLIB 动态代理实现 9. 总结 1. 代理模式 代理模式&#xf…

Mac查看系统状态

syatem profiler mac系统中提供了system profiler来查看系统的详细信息,包括硬件、网络以及安装的软件 Console 显示了系统上的日志文件信息,有助于诊断问题 Activity Monitor 可以提供正在运行的系统的相关信息 https://zhhll.icu/2021/Mac/查看系统…

【云原生】一文学会Docker存储所有特性

目录 1.Volumes 1.Volumes使用场景 2.持久将资源存放 3. 只读挂载 2.Bind mount Bind mounts使用场景 3.tmpfs mounts使用场景 4.Bind mounts和Volumes行为上的差异 5.docker file将存储内置到镜像中 6.volumes管理 1.查看存储卷 2.删除存储卷 3.查看存储卷的详细信息…

Java课题笔记~Maven基础

2、Maven 基础 2.1 Maven安装与配置 下载安装 配置:修改安装目录/conf/settings.xml 本地仓库:存放的是下载的jar包 中央仓库:要从哪个网站去下载jar包 - 阿里云的仓库 2.2 创建Maven项目

MySQL数据库 【索引事务】

目录 一、概念 二、索引的优缺点 1、索引的优点 2、索引的缺陷 三、索引的使用 1、查看索引 2、创建索引 3、删除索引 四、索引底层的数据结构 1、B树 2、B树 五、索引事务 1、概念和回滚 2、事务的使用 3、事务的基本特性 4、并发会遇到的问题 &#xff08…

jenkins执行jmeter时,报Begin size 1 is not equal to fixed size 5

jenkins执行jmeter脚本的时候一直提示如下错误: Tidying up ... Fri Jul 28 17:03:53 CST 2023 (1690535033178) Error generating the report: org.apache.jmeter.report.dashboard.GenerationException: Error while processing samples: Consumer failed wi…

游游的排列构造

示例1 输入 5 2 输出 3 1 5 2 4 示例2 输入 5 3 输出 2 1 4 3 5 #include<bits/stdc.h> using namespace std; typedef long long ll; const int N1e55; int n,k; int main(){scanf("%d%d",&n,&k);int xn-k1;int yn-k;int f1;for(int i1;i&l…

产品经理如何平衡用户体验与商业价值?

近期负责前端产品设计工作的小李忍不住抱怨&#xff1a;公司总是要求客户第一&#xff0c;实现客户良好体验&#xff0c;但在实际操作过程中&#xff0c;面向用户 体验提升的需求&#xff0c;研发资源计划几乎很难排上&#xff0c;资源都放在公司根据业务价值排序的需求…

大家做性能测试都用什么工具

在进行测试时&#xff0c;选择适合的测试工具至关重要&#xff0c;因为优秀的测试工具能够显著提高工作效率。对于性能测试和自动化测试而言&#xff0c;大多数人会选择传统的JMeter等工具&#xff0c;然而这些工具存在学习成本高、使用门槛高的问题。 因此&#xff0c;我在这…

intellij 编辑器内性能提示

介绍 IntelliJ IDEA已经出了最新版的2023.2&#xff0c;最耀眼的功能无法两个 AI Assistant编辑器内性能提示 AI Assistant 已经尝试过了是限定功能&#xff0c;因为是基于open ai,所以限定的意思是国内无法使用&#xff0c;今天我们主要介绍是编辑器内性能提示 IntelliJ Pr…

Flink回撤流

1.回撤流定义&#xff08;RetractStream&#xff09; Flink 的回撤流是指在 Flink 的流处理算法中&#xff0c;撤回已经发送到下游节点的数据。这是因为在实际应用场景中&#xff0c;有些错误数据可能会发送到下游节点&#xff0c;因此需要回撤流以保证数据的准确性。 回撤流…

EP4CE6E22C8N Error: Can‘t recognize silicon ID for device 1

经过各种排查&#xff0c;发现是AS配置不对&#xff0c;仅供参考 工程 参考某处的工程画板配置的FPGA板子&#xff0c;用于学习入门FPGA。 烧录sof文件是正常的&#xff0c;并能正常运行。 但是烧录jic是failed&#xff0c;查看报错为&#xff1a;Error: Can’t recognize si…

渗透测试:Linux提权精讲(二)之sudo方法第二期

目录 写在开头 sudo expect sudo fail2ban sudo find sudo flock sudo ftp sudo gcc sudo gdb sudo git sudo gzip/gunzip sudo iftop sudo hping3 sudo java 总结与思考 写在开头 本文在上一篇博客的基础上继续讲解渗透测试的sudo提权方法。相关内容的介绍与背…