PostgreSQL的学习心得和知识总结(一百四十九)|psql 的使用技巧:设置、预设、回显和已保存的查询

news2024/9/23 11:25:24

注:提前言明 本文借鉴了以下博主、书籍或网站的内容,其列表如下:

1、参考书籍:《PostgreSQL数据库内核分析》
2、参考书籍:《数据库事务处理的艺术:事务管理与并发控制》
3、PostgreSQL数据库仓库链接,点击前往
4、日本著名PostgreSQL数据库专家 铃木启修 网站主页,点击前往
5、参考书籍:《PostgreSQL中文手册》
6、参考书籍:《PostgreSQL指南:内幕探索》,点击前往
7、参考书籍:《事务处理 概念与技术》
8、Magic Tricks for Postgres psql: Settings, Presets, Echo, and Saved Queries,点击前往


1、本文内容全部来源于开源社区 GitHub和以上博主的贡献,本文也免费开源(可能会存在问题,评论区等待大佬们的指正)
2、本文目的:开源共享 抛砖引玉 一起学习
3、本文不提供任何资源 不存在任何交易 与任何组织和机构无关
4、大家可以根据需要自行 复制粘贴以及作为其他个人用途,但是不允许转载 不允许商用 (写作不易,还请见谅 💖)
5、本文内容基于PostgreSQL master源码开发而成


psql 的使用技巧:设置、预设、回显和已保存的查询

  • 文章快速说明索引
  • 功能使用背景说明
  • 一些最有用的 psql 命令
    • 格式化 psql 输出
    • psql 输出中的表格列边框
    • 在 psql 中显示查询运行时间
    • 在 psql 中为空值创建预设
    • 您的 psql 历史记录
    • 将 PSQL 命令回显为 SQL
    • 回显所有 Postgres psql 查询
    • 使用 .psqlrc 设置您的默认 psql 体验
    • 自定义提示行
    • 保存在 psqlrc 文件中的查询
  • 尝试使用 psql 环境



文章快速说明索引

学习目标:

做数据库内核开发久了就会有一种 少年得志,年少轻狂 的错觉,然鹅细细一品觉得自己其实不算特别优秀 远远没有达到自己想要的。也许光鲜的表面掩盖了空洞的内在,每每想到于此,皆有夜半临渊如履薄冰之感。为了睡上几个踏实觉,即日起 暂缓其他基于PostgreSQL数据库的兼容功能开发,近段时间 将着重于学习分享Postgres的基础知识和实践内幕。


学习内容:(详见目录)

1、psql 的使用技巧:设置、预设、回显和已保存的查询


学习时间:

2024年07月23日 20:19:05


学习产出:

1、PostgreSQL数据库基础知识回顾 1个
2、CSDN 技术博客 1篇
3、PostgreSQL数据库内核深入学习


注:下面我们所有的学习环境是Centos8+PostgreSQL master +Oracle19C+MySQL8.0

postgres=# select version();
                                                  version                                                   
------------------------------------------------------------------------------------------------------------
 PostgreSQL 18devel on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-21), 64-bit
(1 row)

postgres=#

#-----------------------------------------------------------------------------#

SQL> select * from v$version;          

BANNER        Oracle Database 19c EE Extreme Perf Release 19.0.0.0.0 - Production	
BANNER_FULL	  Oracle Database 19c EE Extreme Perf Release 19.0.0.0.0 - Production Version 19.17.0.0.0	
BANNER_LEGACY Oracle Database 19c EE Extreme Perf Release 19.0.0.0.0 - Production	
CON_ID 0


#-----------------------------------------------------------------------------#

mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.27    |
+-----------+
1 row in set (0.06 sec)

mysql>

功能使用背景说明

在我使用 Postgres psql cli 的过程中,我从 Crunchy Data 的同事那里学到了一些好习惯,这些习惯让我的终端数据库环境更易于使用。我想分享一些我发现的我最喜欢的东西,它们可以让 Postgres 变得更好。如果您刚刚开始使用 psql,或者还没有尝试太多默认设置,那么这篇文章就是为您准备的。我将带您了解一些最友好的 psql 设置以及如何创建您自己的预设设置文件。

一些最有用的 psql 命令

格式化 psql 输出

Postgres 具有扩展显示模式,它将以列和数据批次的形式读取查询结果,而不是以向右扩展显示的大量列列表的形式读取。

扩展显示示例如下所示:

-[ RECORD 1 ]------------------------------
id         | 1
name       | Alice Johnson
position   | Manager
department | Sales
salary     | 75000.00
-[ RECORD 2 ]------------------------------
id         | 2
name       | Bob Smith
position   | Developer
department | Engineering
salary     | 65000.00
--Automatically format expanded display for wide columns
\x auto

如果您刚刚开始并想尝试这些命令,我​​有一个关于使用基本 psql 的教程。


psql 输出中的表格列边框

如果您不使用扩展显示,您可以让 psql 使用 \pset linestyle来制作一些精美的列轮廓。

--Outline table borders and separators using Unicode characters
\pset linestyle unicode

这将获得如下查询输出:

[postgres@localhost:~/test/bin]$ ./psql 
psql (18devel)
Type "help" for help.

postgres=# \pset 
border                   1
columns                  0
csv_fieldsep             ','
expanded                 off
fieldsep                 '|'
fieldsep_zero            off
footer                   on
format                   aligned
linestyle                ascii
null                     ''
numericlocale            off
pager                    1
pager_min_lines          0
recordsep                '\n'
recordsep_zero           off
tableattr                
title                    
tuples_only              off
unicode_border_linestyle single
unicode_column_linestyle single
unicode_header_linestyle single
xheader_width            full
postgres=# 
postgres=# select * from t1;
 id |    name    
----+------------
  1 | Oracle
  2 | MySQL
  3 | PostgreSQL
(3 rows)

postgres=# \pset border 2
Border style is 2.
postgres=# select * from t1;
+----+------------+
| id |    name    |
+----+------------+
|  1 | Oracle     |
|  2 | MySQL      |
|  3 | PostgreSQL |
+----+------------+
(3 rows)

postgres=# \pset linestyle unicode
Line style is unicode.
postgres=# select * from t1;
┌────┬────────────┐
│ id │    name    │
├────┼────────────┤
│  1 │ Oracle     │
│  2 │ MySQL      │
│  3 │ PostgreSQL │
└────┴────────────┘
(3 rows)

postgres=#

在 psql 中显示查询运行时间

这将在底部为您提供查询运行时间(以毫秒为单位)的结果:

-- Always show query time
\timing

在 psql 中为空值创建预设

这将适用于表情符号或任何兼容 utf-8 的内容:

-- Set Null char output to differentiate it from empty string
\pset null '☘️'
postgres=# select null;
┌──────────┐
│ ?column? │
├──────────┤
│          │
└──────────┘
(1 row)

postgres=# \pset null '☘️'
Null display is "☘️".
postgres=# 
postgres=# select null;
┌──────────┐
│ ?column? │
├──────────┤
│ ☘️        │
└──────────┘
(1 row)

postgres=#

您的 psql 历史记录

您可以为您的 psql 命令会话创建历史记录文件,如下所示:

-- Creates a history file for each database in your config directory CHECK IF THIS IS RIGHT
\set HISTFILE ~/.config/psql/psql_history-:DBNAME

-- Number of commands to save in history
\set HISTSIZE 2000

若是没有设置,如下:

[postgres@localhost:~]$ find . -name *psql_history*
./.psql_history
[postgres@localhost:~]$ 
[postgres@localhost:~]$ head -n 5 ./.psql_history
create table t2 (id int,id2 posint);
select create_distributed_table('t2', 'id');
\d
drop domain posint cascade;
drop table t1;
[postgres@localhost:~]$

将 PSQL 命令回显为 SQL

任何 psql 斜线命令(例如 \d)都会针对 Postgres 的系统表运行。您可以使用 psql echo 命令显示给定命令使用的查询,这可以让您深入了解 Postgres 的内部表、目录和其他命名约定。

-- output any SQL run by psql slash commands
\set ECHO_HIDDEN on

-- short name of ECHO_HIDDEN on
-E

现在让 echo 显示一些东西。使用以下命令进行表查找:

\dt+

现在您将看到它向您回显了用于获取该数据的查询,并且在底部显示了 \dt+ 的正常结果:

[postgres@localhost:~/test/bin]$ ./psql -E
psql (18devel)
Type "help" for help.

postgres=# \d+
/******** QUERY *********/
SELECT n.nspname as "Schema",
  c.relname as "Name",
  CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm' THEN 'materialized view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 't' THEN 'TOAST table' WHEN 'f' THEN 'foreign table' WHEN 'p' THEN 'partitioned table' WHEN 'I' THEN 'partitioned index' END as "Type",
  pg_catalog.pg_get_userbyid(c.relowner) as "Owner",
  CASE c.relpersistence WHEN 'p' THEN 'permanent' WHEN 't' THEN 'temporary' WHEN 'u' THEN 'unlogged' END as "Persistence",
  am.amname as "Access method",
  pg_catalog.pg_size_pretty(pg_catalog.pg_table_size(c.oid)) as "Size",
  pg_catalog.obj_description(c.oid, 'pg_class') as "Description"
FROM pg_catalog.pg_class c
     LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
     LEFT JOIN pg_catalog.pg_am am ON am.oid = c.relam
WHERE c.relkind IN ('r','p','v','m','S','f','')
      AND n.nspname <> 'pg_catalog'
      AND n.nspname !~ '^pg_toast'
      AND n.nspname <> 'information_schema'
  AND pg_catalog.pg_table_is_visible(c.oid)
ORDER BY 1,2;
/************************/

                                  List of relations
 Schema | Name | Type  |  Owner   | Persistence | Access method | Size  | Description 
--------+------+-------+----------+-------------+---------------+-------+-------------
 public | t1   | table | postgres | permanent   | heap          | 16 kB | 
(1 row)

postgres=#

这块功能的源码解析可以查看本人之前的博客:

  • PostgreSQL的学习心得和知识总结(一百四十)|深入理解PostgreSQL数据库 psql工具 \set 变量内部及HOOK机制,点击前往

回显所有 Postgres psql 查询

您还可以让 psql 回显其运行的所有查询:

-- Have psql echo back queries
\set ECHO queries

-- Short name of echo queries
-e
[postgres@localhost:~/test/bin]$ ./psql -e
psql (18devel)
Type "help" for help.

postgres=# \d
        List of relations
 Schema | Name | Type  |  Owner   
--------+------+-------+----------
 public | t1   | table | postgres
(1 row)

postgres=# select * from t1;
select * from t1;
 id |    name    
----+------------
  1 | Oracle
  2 | MySQL
  3 | PostgreSQL
(3 rows)

postgres=# \q
[postgres@localhost:~/test/bin]$ ./psql -e -E
psql (18devel)
Type "help" for help.

postgres=# \d
/******** QUERY *********/
SELECT n.nspname as "Schema",
  c.relname as "Name",
  CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm' THEN 'materialized view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 't' THEN 'TOAST table' WHEN 'f' THEN 'foreign table' WHEN 'p' THEN 'partitioned table' WHEN 'I' THEN 'partitioned index' END as "Type",
  pg_catalog.pg_get_userbyid(c.relowner) as "Owner"
FROM pg_catalog.pg_class c
     LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
     LEFT JOIN pg_catalog.pg_am am ON am.oid = c.relam
WHERE c.relkind IN ('r','p','v','m','S','f','')
      AND n.nspname <> 'pg_catalog'
      AND n.nspname !~ '^pg_toast'
      AND n.nspname <> 'information_schema'
  AND pg_catalog.pg_table_is_visible(c.oid)
ORDER BY 1,2;
/************************/

        List of relations
 Schema | Name | Type  |  Owner   
--------+------+-------+----------
 public | t1   | table | postgres
(1 row)

postgres=# select * from t1;
select * from t1;
 id |    name    
----+------------
  1 | Oracle
  2 | MySQL
  3 | PostgreSQL
(3 rows)

postgres=#

如果您正在从文件运行查询,或者它们是 psqlrc 中的预设,并且希望查询第二次输出以进行记录保存,那么这将非常有用。

如果您想进一步了解其中任何一个,我有一个关于 ECHO HIDDEN 和 ECHO 查询的基于网络的教程。


使用 .psqlrc 设置您的默认 psql 体验

我列出的所有上述事项都可以设置为每次使用本地 psql 时自动发生。当 psql 启动时,它会查找 .psqlrc 文件,如果存在,它将执行其中的命令。这允许您自定义提示和其他 psql 设置。

您可以使用以下命令查看您是否有 .psqlrc 文件:

ls -l ~/.psqlrc

如果您想在启动 psql 时跳过命令记录,您可以将这些命令添加到文件的开头和结尾:

-- Don't log these commands at the beginning of the file
\set QUIET 1

-- Reset command logging at the end of the file
\set QUIET 0

自定义提示行

psql 的默认提示行只显示数据库名称,没有其他信息。在 psqlrc 文件中,您可以更改 psql 提示行以使用有关数据库主机和会话的不同信息组合。我个人喜欢在这里使用日期和时间,因为我要保存会话以供以后参考。

-- Create a prompt with host, database name, date, and time
\set PROMPT1 '%m@%/ %`date "+%Y-%m-%d %H:%M:%S"` '

或者,如下:

[postgres@localhost:~/test/bin]$ cat ~/.psqlrc
\set PROMPT1 '%m@%n-%/-%> %`date "+%Y-%m-%d %H:%M:%S"` =%# '
[postgres@localhost:~/test/bin]$ 
[postgres@localhost:~/test/bin]$ ./psql
psql (18devel)
Type "help" for help.

[local]@postgres-postgres-5432 2024-07-24 00:22:26 =# select * from t1;
 id |    name    
----+------------
  1 | Oracle
  2 | MySQL
  3 | PostgreSQL
(3 rows)

[local]@postgres-postgres-5432 2024-07-24 00:22:33 =# exit
[postgres@localhost:~/test/bin]$
// src/bin/psql/prompt.c

/*--------------------------
 * get_prompt
 *
 * Returns a statically allocated prompt made by interpolating certain
 * tcsh style escape sequences into pset.vars "PROMPT1|2|3".
 * (might not be completely multibyte safe)
 *
 * Defined interpolations are:
 * %M - database server "hostname.domainname", "[local]" for AF_UNIX
 *		sockets, "[local:/dir/name]" if not default
 * %m - like %M, but hostname only (before first dot), or always "[local]"
 * %p - backend pid
 * %> - database server port number
 * %n - database user name
 * %/ - current database
 * %~ - like %/ but "~" when database name equals user name
 * %w - whitespace of the same width as the most recent output of PROMPT1
 * %# - "#" if superuser, ">" otherwise
 * %R - in prompt1 normally =, or ^ if single line mode,
 *			or a ! if session is not connected to a database;
 *		in prompt2 -, *, ', or ";
 *		in prompt3 nothing
 * %x - transaction status: empty, *, !, ? (unknown or no connection)
 * %l - The line number inside the current statement, starting from 1.
 * %? - the error code of the last query (not yet implemented)
 * %% - a percent sign
 *
 * %[0-9]		   - the character with the given decimal code
 * %0[0-7]		   - the character with the given octal code
 * %0x[0-9A-Fa-f]  - the character with the given hexadecimal code
 *
 * %`command`	   - The result of executing command in /bin/sh with trailing
 *					 newline stripped.
 * %:name:		   - The value of the psql variable 'name'
 * (those will not be rescanned for more escape sequences!)
 *
 * %[ ... %]	   - tell readline that the contained text is invisible
 *
 * If the application-wide prompts become NULL somehow, the returned string
 * will be empty (not NULL!).
 *--------------------------
 */

char *
get_prompt(promptStatus_t status, ConditionalStack cstack);

保存在 psqlrc 文件中的查询

这个 .psqlrc 文件看起来很酷,对吧?但等等……还有更多!您可以将查询添加到此文件,以便只需使用非常简单的 psql 输入即可运行它们。

将这些示例查询添加到 psqlrc,用于长时间运行的查询、缓存命中率、unused_indexes 和表大小。

\set long_running 'SELECT pid, now() - pg_stat_activity.xact_start AS duration, query, state FROM pg_stat_activity WHERE (now() - pg_stat_activity.xact_start) > interval ''5 minutes'' ORDER by 2 DESC;'

\set cache_hit 'SELECT ''index hit rate'' AS name, (sum(idx_blks_hit)) / nullif(sum(idx_blks_hit + idx_blks_read),0) AS ratio FROM pg_statio_user_indexes UNION ALL SELECT ''table hit rate'' AS name, sum(heap_blks_hit) / nullif(sum(heap_blks_hit) + sum(heap_blks_read),0) AS ratio FROM pg_statio_user_tables;'

\set unused_indexes 'SELECT schemaname || ''.'' || relname AS table, indexrelname AS index, pg_size_pretty(pg_relation_size(i.indexrelid)) AS index_size, idx_scan as index_scans FROM pg_stat_user_indexes ui JOIN pg_index i ON ui.indexrelid = i.indexrelid WHERE NOT indisunique AND idx_scan < 50 AND pg_relation_size(relid) > 5 * 8192 ORDER BY pg_relation_size(i.indexrelid) / nullif(idx_scan, 0) DESC NULLS FIRST, pg_relation_size(i.indexrelid) DESC;'

\set table_sizes 'SELECT c.relname AS name, pg_size_pretty(pg_table_size(c.oid)) AS size FROM pg_class c LEFT JOIN pg_namespace n ON (n.oid = c.relnamespace) WHERE n.nspname NOT IN (''pg_catalog'', ''information_schema'') AND n.nspname !~ ''^pg_toast'' AND c.relkind=''r'' ORDER BY pg_table_size(c.oid) DESC;'

案例,如下:

[postgres@localhost:~/test/bin]$ ./psql
psql (18devel)
Type "help" for help.

[local]@postgres-postgres-5432 2024-07-24 00:28:24 =# :table_sizes;
 name | size  
------+-------
 t1   | 16 kB
(1 row)

[local]@postgres-postgres-5432 2024-07-24 00:28:27 =#

尝试使用 psql 环境

我们希望这些内容能给您一些关于尝试使用 psql 环境的想法。这非常简单而且很有趣!成功秘诀:

  • 优先帮助自己处理每天使用但需要花费时间的事情。您是否每周在数据库上运行一次查询?将其放入 psqlrc 文件中,以便下次使用时可以立即找到。
  • 如果您远程连接到数据库,请不要太过分。如果您不使用本地连接到数据库并直接远程连接,请不要创建大量特殊工具,因为使用不同的环境可能会很麻烦。
  • 查看我们的基本 psql 和 ECHO HIDDEN 和 ECHO 查询教程,以便在 Web 浏览器中尝试这些内容

我们的 Postgres 提示页面中还有大量其他方便的 psql 技巧。

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

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

相关文章

nms概念

nms基本概念&#xff1a;非极大值抑制 用途&#xff1a;在做目标检测的时候&#xff0c;往往会生成很多很多候选框&#xff0c;在做目标检测的时候&#xff0c;往往会生成很多很多候选框。 处理流程&#xff1a; 1.对某一类按score对候选框进行排序&#xff0c;并选出score最…

ffmpeg把pcm封装为wav

note 1.wav格式中&#xff0c;音频数据未经过压缩&#xff0c;直接封装即可 2.对于编码器的选择&#xff0c;应选择和pcm裸数据一致的编码器(本次实际不须编码) version #define LIBSWRESAMPLE_VERSION_MAJOR 2 #define LIBSWRESAMPLE_VERSION_MINOR 9 #define LIBSWRESAM…

Python网络爬虫详解:实战豆瓣电影信息采集

文章目录 前言一、爬虫是什么&#xff1f;二、常用库及其作用1.Requests2.BeautifulSoup3. lxml4. Scrapy5. Selenium6. PyQuery7. Pandas8. JSON9. Time 三、实现步骤步骤一&#xff1a;环境准备步骤二&#xff1a;数据采集步骤三&#xff1a;数据处理步骤四&#xff1a;数据存…

【数据分享】2008-2022年我国省市县三级的逐日NO2数据(excel\shp格式)

空气质量数据是在我们日常研究中经常使用的数据&#xff01;之前我们给大家分享了2000-2022年的省市县三级的逐日PM2.5数据、2013-2022年的省市县三级的逐日CO数据和2013-2022年的省市县三级的逐日SO2数据&#xff08;均可查看之前的文章获悉详情&#xff09;&#xff01; 本次…

前端 SSE 长连接

使用 const options {withCredentials: true, // 默认 false}const eventSource new EventSource(/api, options);eventSource.addEventListener(open, () > {});eventSource.onmessage (event) > {}; // 或addEventListener(message,callback)eventSource.addEvent…

BGP选路之AS-PATH

原理概述 当一台BGP路由器中存在多条去往同一目标网络的BGP路由时&#xff0c;BGP协议会对这些BGP路由的属性进行比较&#xff0c;以确定去往该目标网络的最优BGP路由。首先要比较的属性是 Preferred Value&#xff0c;然后是Local Preference&#xff0c;再次是路由生成方式&a…

Ansible的脚本-----playbook剧本【上】

目录 1.playbook剧本组成 2.playbook剧本实战演练 2.1 实战演练一&#xff1a;给被管理主机安装httpd服务 2.2 实战演练二&#xff1a;定义、引用变量 2.3 实战演练三&#xff1a;指定远程主机sudo切换用户 2.4 实战演练四&#xff1a;when条件判断 2.5 实战演练五&…

Docker Compose V2 安装 ClickHouse v20.6.8.5 经验分享

前言 ClickHouse 是一款开源的分布式列式数据库管理系统,专门设计用于高性能的大数据分析和查询。 目前项目中用到的一个场景是将mongo的数据同步到clickhouse,使用clickhouse做报表,后续也将分享同步和使用方案 使用 Docker Compose 部署单机版,小项目和自己测试够用了,生…

【C#】visual studio打包winForm(依赖DLL)为安装程序exe

0.简介 IDE&#xff1a;VS2022 平台&#xff1a;C# .NetFramework4.7 WinForm界面 有GDAL、EEplus库的依赖&#xff0c;所以在其他未安装环境的电脑中功能无法使用。 1. 安装 1.1 运行文件 在VS扩展中选择管理扩展&#xff0c;Microsoft Visual Studio Installer Projects …

C#测试控制台程序调用Quartz.NET的基本用法

Quartz.Net是常用的任务调用框架之一&#xff0c;既能在客户端程序中使用&#xff0c;也支持在网页程序后台调用。本文结合参考文献4中的示例代码学习其在控制台程序中的基本用法。   VS2022新建控制台项目&#xff0c;在Nuget包管理器中搜索并安装Quartz包&#xff0c;如下所…

51单片机嵌入式开发:18、STC89C52RC嵌入式DS1302实时时钟实验及数码管显示

STC89C52RC嵌入式DS1302实时时钟实验及数码管显示 STC89C52RC嵌入式DS1302实时时钟实验及数码管显示1 概述1.1 DS1302简介1.2 DS1302功能和特点1.3 DS1302工作原理1.4 DS1302应用领域 2 DS1302设计原理2.1 引脚说明2.2 寄存器说明及使用&#xff08;1&#xff09;命令cmd字节说…

Redis的缓存问题:缓存穿透、缓存击穿和缓存雪崩

目录 一、缓存穿透 1、问题描述 2、解决方案 二、缓存击穿 1、问题描述 2、解决方案 三、缓存雪崩 1、问题描述 2、解决方案 3、雪崩案例 一、缓存穿透 1、问题描述 缓存穿透指的是⼤量请求的 key根本不存在于缓存中&#xff0c;每次针对此key的请求从缓存获取不到…

报红:找不到名称ref ts(2304)、‘ref‘ is not defined. eslint(no-undef)

接上篇 在上篇介绍了使用 unplugin-auto-import 和 unplugin-vue-components 配置完成后&#xff0c;项目可以正常运行&#xff0c;并且页面也正常显示&#xff0c;但vscode里就是报红 这个报红可能是由于 ts 发出的&#xff0c;也可能是由于 eslint 发出的 具体可以用鼠标…

如何使用 API list 极狐GitLab 群组中的镜像仓库?

GitLab 是一个全球知名的一体化 DevOps 平台&#xff0c;很多人都通过私有化部署 GitLab 来进行源代码托管。极狐GitLab &#xff1a;https://gitlab.cn/install?channelcontent&utm_sourcecsdn 是 GitLab 在中国的发行版&#xff0c;专门为中国程序员服务。可以一键式部署…

某数据泄露防护(DLP)系统NetSecConfigAjax接口SQL注入漏洞复现 [附POC]

文章目录 某数据泄露防护(DLP)系统NetSecConfigAjax接口SQL注入漏洞复现 [附POC]0x01 前言0x02 漏洞描述0x03 影响版本0x04 漏洞环境0x05 漏洞复现1.访问漏洞环境2.构造POC3.复现某数据泄露防护(DLP)系统NetSecConfigAjax接口SQL注入漏洞复现 [附POC] 0x01 前言 免责声明:请…

云计算实训13——DNS域名解析、ntp时间服务器配置、主从DNS配置、多区域DNS搭建

一、DNS域名解析 1.正向解析 将域名解析为IP地址 DNS正向解析核心配置 (1)安装bind [rootdns ~]# yum -y install bind (2)编辑配置文件 编辑named.conf文件&#xff0c;限定访问权限 [rootdns ~]# vim /etc/named.conf 编辑named.rfc文件&#xff0c;指定要访问的域名 [ro…

大语言模型推理优化--键值缓存--Key-value Cache

文章目录 一、生成式预训练语言模型 GPT 模型结构二、FastServe 框架三、Key-value Cache1.大模型推理的冗余计算2.Self Attention3.KV Cache 一、生成式预训练语言模型 GPT 模型结构 目前&#xff0c;深度神经网络推理服务系统已经有一些工作针对生成式预训练语言模型 GPT 的独…

【Gin】架构的精妙编织:Gin框架中组合模式的革新实践与技术深度解析(上)

【Gin】架构的精妙编织&#xff1a;Gin框架中组合模式的革新实践与技术深度解析(上) 大家好 我是寸铁&#x1f44a; 【Gin】架构的精妙编织&#xff1a;Gin框架中组合模式的革新实践与技术深度解析(上)✨ 喜欢的小伙伴可以点点关注 &#x1f49d; 前言 本次文章分为上下两部分…

QT--线程

一、线程QThread QThread 类提供不依赖平台的管理线程的方法&#xff0c;如果要设计多线程程序&#xff0c;一般是从 QThread继承定义一个线程类&#xff0c;在自定义线程类里进行任务处理。qt拥有一个GUI线程,该线程阻塞式监控窗体,来自任何用户的操作都会被gui捕获到,并处理…

Umi-OCR:功能强大且易于使用的本地照片识别软件

Umi-OCR是一款开源且免费的离线OCR&#xff08;光学字符识别&#xff09;软件&#xff0c;可让您轻松从照片中提取文本。它支持多种语言&#xff0c;并具有许多其他功能使其成为照片识别任务的绝佳选择。 Umi-OCR的优势 离线操作&#xff1a; Umi-OCR无需互联网连接即可工作&…