Data Vault 初探(五) —— 定期裝載_SQL

說明:
1. 定期裝載的周期為每天一次。
2. 每天裝載自上次裝載后的變化數據
3. 建立源數據庫的過渡表用于CDC
4. 建立cdc_time表用于基于時間戳的CDC
5. 因為源庫上只有訂單銷售表有時間屬性,所以除了sales_order和sales_order_item拉取變化數據外,其它表都整體拉取到過渡區。實際環境中建議在源表設計上應該有created和last_updated兩個時間戳類型的字段。
6. 下表匯總了源庫各表的CDC方式

源數據庫表

過渡表

抽取模式

city

city_stg

整體、拉取

province

province_stg

整體、拉取

customer

customer_stg

整體、拉取

product_catagory

product_catagory_stg

整體、拉取

product

product_stg

整體、拉取

sales_order

sales_order_stg

CDC(每天)、拉取

sales_order_item

sales_order_item_stg

CDC(每天)、拉取


使用下面的腳本建立過渡區表和cdc_time表。

CREATE TABLE province_stg (province_id varchar(2),province_name varchar(20)
) ;CREATE TABLE product_catagory_stg (product_catagory_id varchar(2),product_catagory_name varchar(20)
) ;CREATE TABLE city_stg (city_id varchar(4),city_name varchar(20),province_id varchar(2)
) ;CREATE TABLE customer_stg (customer_id int(11),customer_name varchar(20),city_id varchar(4),cust_post_code varchar(6),cust_address varchar(50),ship_post_code varchar(6),ship_address varchar(50)
) ;CREATE TABLE product_stg (product_id int(11),product_name varchar(20),unit_price decimal(10,4),product_catagory_id varchar(2)
) ;CREATE TABLE sales_order_stg (sales_order_id int(11),order_time datetime,entry_time datetime,customer_id int(11),amount decimal(12,4),allocate_time datetime,packing_time datetime,ship_time datetime,receive_time datetime
) ;CREATE TABLE sales_order_item_stg (sales_order_item_id int(11),sales_order_id int(11),product_id int(11),unit_price decimal(10,4),quantity int(11)
) ;CREATE TABLE cdc_time
(last_load date,current_load date
);-- 插入數據倉庫開始日期
INSERT INTO cdc_time VALUES ('2015-03-01', '2015-03-01') ;
COMMIT ;

sales_order_item表是基于sales_order.sales_order_id更新的。為了避免對sales_order表的二次查詢,希望在對sales_order做CDC時同時獲取到sales_order_id用于后續的sales_order_item表的CDC。MySQL數據庫本身沒有提供類似于Oracle的returning這樣的語法,所以用內存表+觸發器的方式實現。使用下面的腳本建立內存表和sales_order_stg表上的insert觸發器。

USE dv;-- 建立內存表
CREATE TABLE sales_order_stg_insert ENGINE MEMORY 
SELECT sales_order_id, entry_time, allocate_time, packing_time, ship_time, receive_time 
FROM sales_order_stg WHERE FALSE;-- 建立insert觸發器
DELIMITER // DROP TRIGGER tr_sales_order_stg_insert_after //  
CREATE  TRIGGER tr_sales_order_stg_insert_after AFTER INSERT ON sales_order_stg   FOR EACH ROW BEGIN  INSERT INTO sales_order_stg_insert VALUES (NEW.sales_order_id, NEW.entry_time, NEW.allocate_time, NEW.packing_time, NEW.ship_time, NEW.receive_time);  END;  
//  DELIMITER ;

sales_order表的幾個時間字段可能修改,所以

新增訂單的條件是:
entry_time >= @last_load and entry_time < @current_load
修改訂單版本的條件是:
entry_time < @last_load and (allocate_time >= @last_load and allocate_time < @current_load
or packing_time >= @last_load and packing_time < @current_load
or ship_time >= @last_load and ship_time < @current_load
or receive_time >= @last_load and receive_time < @current_load)
sales_order_item表只基于sales_order.sales_order_id的新增訂單更新的。

使用下面的腳本進行每天定期裝載。

use dv;-- 設置附屬表的截止時間和生效時間
SET @pre_date = SUBDATE(CURRENT_DATE,1) ;
-- 設置CDC的上限時間
update cdc_time set current_load = current_date ;
select @last_load:=last_load,@current_load:=current_load from cdc_time;-- 裝載過渡表
truncate table customer_stg;
truncate table city_stg;
truncate table province_stg;
truncate table product_stg;
truncate table product_catagory_stg;
truncate table sales_order_stg;
truncate table sales_order_item_stg;
truncate table sales_order_stg_insert;insert into province_stg select * from province;
insert into city_stg select * from city;
insert into customer_stg select * from customer;
insert into product_catagory_stg select * from product_catagory;
insert into product_stg select * from product;
insert into sales_order_stg
select a.* from sales_order a
where entry_time >= @last_load and entry_time < @current_load
or (entry_time < @last_load and (allocate_time >= @last_load and allocate_time < @current_loador packing_time >= @last_load and packing_time < @current_loador ship_time >= @last_load and ship_time < @current_loador receive_time >= @last_load and receive_time < @current_load));
insert into sales_order_item_stg
select a.* from sales_order_item a, sales_order_stg_insert b
where a.sales_order_id = b.sales_order_idand b.entry_time >= @last_load and b.entry_time < @current_load;/*** 裝載中心表 ***/
insert into hub_product_catagory (product_catagory_id,record_source)  
select a.product_catagory_id,'source.product_catagory' 
from product_catagory_stg a left join hub_product_catagory b on a.product_catagory_id = b.product_catagory_id
where b.product_catagory_id is null;  insert into hub_customer (customer_id,record_source)  
select a.customer_id,'source.customer' 
from customer_stg a left join hub_customer b on a.customer_id = b.customer_id
where b.customer_id is null;  insert into hub_product (product_id,record_source)  
select a.product_id,'source.product' 
from product_stg a left join hub_product b on a.product_id = b.product_id
where b.product_id is null;  insert into hub_sales_order (sales_order_id,record_source)  
select sales_order_id,'source.sales_order' from sales_order_stg where entry_time >= @last_load and entry_time < @current_load; 
/*** 裝載中心表 ***//*** 裝載鏈接表 ***/
insert into link_order_customer (hub_sales_order_id,hub_customer_id,record_source)  
select hub_sales_order_id,hub_customer_id,'hub_sales_order,source.sales_order,hub_customer,source.customer'  
from hub_sales_order,sales_order_stg,hub_customer,customer_stg 
where hub_sales_order.sales_order_id = sales_order_stg.sales_order_id  and hub_customer.customer_id = customer_stg.customer_id  and sales_order_stg.customer_id = customer_stg.customer_idand sales_order_stg.entry_time >= @last_load and sales_order_stg.entry_time < @current_load;insert into link_order_product (hub_sales_order_id,hub_product_id,record_source)  
select hub_sales_order_id,hub_product_id,'hub_sales_order,hub_product,source.sales_order_item'  
from hub_sales_order,hub_product,sales_order_item_stg
where hub_sales_order.sales_order_id = sales_order_item_stg.sales_order_id  and hub_product.product_id = sales_order_item_stg.product_id;  insert into link_product_catagory (hub_product_id,hub_product_catagory_id,record_source)
select t1.hub_product_id hub_product_id, t1.hub_product_catagory_id hub_product_catagory_id,
'hub_product,product,hub_product_catagory' record_source
from 
(
select t2.hub_product_id hub_product_id, t3.hub_product_catagory_id hub_product_catagory_id
from product_stg t1, hub_product t2, hub_product_catagory t3
where t1.product_id = t2.product_id and t1.product_catagory_id = t3.product_catagory_id) t1
left join link_product_catagory t2 on t1.hub_product_id = t2.hub_product_id
where t2.hub_product_id is null;/*** 裝載鏈接表 ***//*** 裝載附屬表 ***/
-- 客戶附屬表
-- 修改老版本的截止日期
update hub_customer t1, sat_customer t2, 
(select customer_id,customer_name,city_name,province_name,cust_post_code,cust_address,ship_post_code,ship_address
from customer_stg t1,city_stg t2,province_stg t3
where t1.city_id = t2.city_id and t2.province_id = t3.province_id) t3
set t2.load_end_dts = @pre_date
where t1.hub_customer_id = t2.hub_customer_id
and t2.load_end_dts = '2200-01-01'
and t1.customer_id = t3.customer_id
and md5(concat(t2.customer_name,t2.city_name,t2.province_name,t2.cust_post_code,t2.cust_address,t2.ship_post_code,t2.ship_address))
<> 
md5(concat(t3.customer_name,t3.city_name,t3.province_name,t3.cust_post_code,t3.cust_address,t3.ship_post_code,t3.ship_address));-- 新增版本
insert into sat_customer   
(hub_customer_id,  
load_end_dts,  
record_source,  
customer_name,  
city_name,  
province_name,  
cust_post_code,  
cust_address,  
ship_post_code,  
ship_address) 
select 
t1.hub_customer_id,  
'2200-01-01',  
'hub_customer,customer,city,province', 
t3.customer_name,  
t3.city_name,  
t3.province_name,  
t3.cust_post_code,  
t3.cust_address,  
t3.ship_post_code,  
t3.ship_address 
from 
hub_customer t1, sat_customer t2, 
(select customer_id,customer_name,city_name,province_name,cust_post_code,cust_address,ship_post_code,ship_address
from customer_stg t1,city_stg t2,province_stg t3
where t1.city_id = t2.city_id and t2.province_id = t3.province_id) t3
where t1.hub_customer_id = t2.hub_customer_id
and t1.customer_id = t3.customer_id
and md5(concat(t2.customer_name,t2.city_name,t2.province_name,t2.cust_post_code,t2.cust_address,t2.ship_post_code,t2.ship_address))
<> 
md5(concat(t3.customer_name,t3.city_name,t3.province_name,t3.cust_post_code,t3.cust_address,t3.ship_post_code,t3.ship_address))
and exists (select 1 from sat_customer where hub_customer_id = t1.hub_customer_id 
and load_end_dts = @pre_date)
and not exists (select 1 from sat_customer where hub_customer_id = t1.hub_customer_id 
and load_end_dts = '2200-01-01');-- 新增記錄
insert into sat_customer   
(hub_customer_id,  
load_end_dts,  
record_source,  
customer_name,  
city_name,  
province_name,  
cust_post_code,  
cust_address,  
ship_post_code,  
ship_address)  
select  
t1.hub_customer_id,  
'2200-01-01',  
'hub_customer,customer,city,province',  
t2.customer_name,  
t2.city_name,  
t2.province_name,  
t2.cust_post_code,  
t2.cust_address,  
t2.ship_post_code,  
t2.ship_address 
from 
(select hub_customer.hub_customer_id, hub_customer.customer_id 
from hub_customer left join sat_customer 
on hub_customer.hub_customer_id = sat_customer.hub_customer_id
where sat_customer.hub_customer_id is null) t1,
(select customer_id,customer_name,city_name,province_name,cust_post_code,cust_address,ship_post_code,ship_address
from customer_stg t1,city_stg t2,province_stg t3
where t1.city_id = t2.city_id and t2.province_id = t3.province_id) t2
where t1.customer_id = t2.customer_id ; -- 訂單_產品附屬表
-- 新增記錄
insert into sat_order_product   
(link_order_product_id,  
load_end_dts,  
record_source,  
unit_price,  
quantity  
)  
select   
t1.link_order_product_id,  
'2200-01-01',  
'link_order_product,hub_sales_order,hub_product,sales_order_item',  
t4.unit_price,  
t4.quantity  
from link_order_product t1,hub_sales_order t2,hub_product t3,sales_order_item_stg t4 
where t1.hub_sales_order_id = t2.hub_sales_order_id  and t1.hub_product_id = t3.hub_product_id  and t4.sales_order_id = t2.sales_order_id  and t4.product_id = t3.product_id;-- 產品附屬表
-- 修改老版本的截止日期
update hub_product t1, sat_product t2, product_stg t3
set t2.load_end_dts = @pre_date
where t1.hub_product_id = t2.hub_product_id
and t2.load_end_dts = '2200-01-01'
and t1.product_id = t3.product_id
and md5(concat(t2.product_name,convert(t2.unit_price,char)))
<> 
md5(concat(t3.product_name,convert(t3.unit_price,char)));-- 新增版本
insert into sat_product 
(hub_product_id,  
load_end_dts,  
record_source,  
product_name,  
unit_price  
)  
select 
t1.hub_product_id,  
'2200-01-01',  
'hub_product,product', 
t3.product_name,  
t3.unit_price
from 
hub_product t1, sat_product t2, product_stg t3
where t1.hub_product_id = t2.hub_product_id
and t1.product_id = t3.product_id
and md5(concat(t2.product_name,convert(t2.unit_price,char)))
<> 
md5(concat(t3.product_name,convert(t3.unit_price,char)))
and exists (select 1 from sat_product where hub_product_id = t1.hub_product_id 
and load_end_dts = @pre_date)
and not exists (select 1 from sat_product where hub_product_id = t1.hub_product_id 
and load_end_dts = '2200-01-01');-- 新增記錄
insert into sat_product  
(hub_product_id,  
load_end_dts,  
record_source,  
product_name,  
unit_price  
)  
select  
t1.hub_product_id,  
'2200-01-01',  
'hub_product,product',  
t2.product_name,  
t2.unit_price
from 
(select hub_product.hub_product_id, hub_product.product_id 
from hub_product left join sat_product 
on hub_product.hub_product_id = sat_product.hub_product_id
where sat_product.hub_product_id is null) t1,
(
select product_id,product_name,unit_price 
from product_stg) t2
where t1.product_id = t2.product_id ; -- 產品類型附屬表
-- 修改老版本的截止日期
update hub_product_catagory t1, sat_product_catagory t2, product_catagory_stg t3
set t2.load_end_dts = @pre_date
where t1.hub_product_catagory_id = t2.hub_product_catagory_id
and t2.load_end_dts = '2200-01-01'
and t1.product_catagory_id = t3.product_catagory_id
and t2.product_catagory_name <> t3.product_catagory_name;-- 新增版本
insert into sat_product_catagory  
(hub_product_catagory_id,  
load_end_dts,  
record_source,  
product_catagory_name  
)   
select 
t1.hub_product_catagory_id,  
'2200-01-01',  
'hub_product_catagory,product_catagory',  
t3.product_catagory_name 
from 
hub_product_catagory t1, sat_product_catagory t2, product_catagory_stg t3
where t1.hub_product_catagory_id = t2.hub_product_catagory_id
and t1.product_catagory_id = t3.product_catagory_id
and t2.product_catagory_name <> t3.product_catagory_name
and exists (select 1 from sat_product_catagory where hub_product_catagory_id = t1.hub_product_catagory_id 
and load_end_dts = @pre_date)
and not exists (select 1 from sat_product_catagory where hub_product_catagory_id = t1.hub_product_catagory_id 
and load_end_dts = '2200-01-01');-- 新增記錄
insert into sat_product_catagory  
(hub_product_catagory_id,  
load_end_dts,  
record_source,  
product_catagory_name  
)  
select  
t1.hub_product_catagory_id,  
'2200-01-01',  
'hub_product_catagory,product_catagory', 
t2.product_catagory_name
from 
(select hub_product_catagory.hub_product_catagory_id, hub_product_catagory.product_catagory_id 
from hub_product_catagory left join sat_product_catagory 
on hub_product_catagory.hub_product_catagory_id = sat_product_catagory.hub_product_catagory_id
where sat_product_catagory.hub_product_catagory_id is null) t1,
(
select product_catagory_id,product_catagory_name
from product_catagory_stg) t2
where t1.product_catagory_id = t2.product_catagory_id ; -- 銷售訂單附屬表
-- 修改老版本的截止日期
update hub_sales_order t1, sat_sales_order t2, sales_order_stg t3
set t2.load_end_dts = @pre_date
where t1.hub_sales_order_id = t2.hub_sales_order_id
and t2.load_end_dts = '2200-01-01'
and t1.sales_order_id = t3.sales_order_id
and 
(t3.entry_time < @last_load and (t3.allocate_time >= @last_load and t3.allocate_time < @current_loador t3.packing_time >= @last_load and t3.packing_time < @current_loador t3.ship_time >= @last_load and t3.ship_time < @current_loador t3.receive_time >= @last_load and t3.receive_time < @current_load));-- 新增版本
insert into sat_sales_order  
(hub_sales_order_id,  
load_end_dts,  
record_source,  
order_time,  
entry_time,  
amount,  
allocate_time,  
packing_time,  
ship_time,  
receive_time  
) 
select 
t1.hub_sales_order_id,  
'2200-01-01',  
'hub_sales_order,sales_order',  
t3.order_time,  
t3.entry_time,  
t3.amount,  
t3.allocate_time,  
t3.packing_time,  
t3.ship_time,  
t3.receive_time 
from 
hub_sales_order t1, sat_sales_order t2, sales_order_stg t3
where t1.hub_sales_order_id = t2.hub_sales_order_id
and t1.sales_order_id = t3.sales_order_id
and 
(t3.entry_time < @last_load and (t3.allocate_time >= @last_load and t3.allocate_time < @current_loador t3.packing_time >= @last_load and t3.packing_time < @current_loador t3.ship_time >= @last_load and t3.ship_time < @current_loador t3.receive_time >= @last_load and t3.receive_time < @current_load))
and exists (select 1 from sat_sales_order where hub_sales_order_id = t1.hub_sales_order_id 
and load_end_dts = @pre_date)
and not exists (select 1 from sat_sales_order where hub_sales_order_id = t1.hub_sales_order_id 
and load_end_dts = '2200-01-01');-- 新增記錄
insert into sat_sales_order  
(hub_sales_order_id,  
load_end_dts,  
record_source,  
order_time,  
entry_time,  
amount,  
allocate_time,  
packing_time,  
ship_time,  
receive_time  
) 
select   
t1.hub_sales_order_id,  
'2200-01-01',  
'hub_sales_order,sales_order',  
t2.order_time,  
t2.entry_time,  
t2.amount,  
t2.allocate_time,  
t2.packing_time,  
t2.ship_time,  
t2.receive_time   
from hub_sales_order t1,sales_order_stg t2 
where t1.sales_order_id = t2.sales_order_idand t2.entry_time >= @last_load and t2.entry_time < @current_load;-- 更新時間戳表的last_load字段
update cdc_time set last_load = current_load ;commit ;

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/86348.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/86348.shtml
英文地址,請注明出處:http://en.pswp.cn/web/86348.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Java虛擬機棧(JVM Stack)詳解與工作流程分析

Java虛擬機棧&#xff08;JVM Stack&#xff09;詳解與工作流程分析 1. 虛擬機棧核心概念 基本特性 線程私有&#xff1a;每個線程在創建時都會分配一個獨立的棧存儲內容&#xff1a; 棧幀&#xff08;Stack Frame&#xff09;&#xff1a;每個方法調用對應一個棧幀 生命周期…

Sonarqube:Jenkins觸發sonar掃描出現UnsupportedClassVersionError錯誤處理

文章目錄 1、問題現象2、問題根因3、解決思路3.1 解決思路13.2 解決思路23.3 解決思路3 1、問題現象 問題現象&#xff1a;在每次Jenkins觸發sonar掃描時&#xff0c;Sonar-scanner掃描器執行都會出現UnsupportedClassVersionError異常&#xff0c;如下&#xff1a; ERROR: …

Spark SQL to_json 函數介紹

目錄 前言函數介紹參數說明示例 前言 在Apache Hive中&#xff0c;并沒有內置的to_json函數。在Apache Spark SQL中確實有to_json函數,它可以用來將結構化數據&#xff08;如結構化類型或MAP類型&#xff09;轉換為JSON字符串。這個功能對于需要將表格數據輸出為JSON格式的場景…

《解鎖前端潛力:自動化流程搭建秘籍》

當項目逐漸從萌芽走向繁茂&#xff0c;中期階段對流程優化與效率提升的需求便愈發迫切。搭建一套自動化測試、持續集成與部署的完整流程&#xff0c;已然成為突破瓶頸、保障代碼質量與上線效率的關鍵密鑰。這不僅是技術的進階&#xff0c;更是思維與協作模式的革新。在踏上構建…

計算機體系結構中的片上系統SoC是什么?

計算機體系結構中的片上系統SoC是什么&#xff1f; 片上系統&#xff08;SoC&#xff0c;System on Chip&#xff09; 是一種將計算機或其他電子系統的多個關鍵組件集成到單一芯片上的集成電路設計。它不僅僅是處理器&#xff08;CPU&#xff09;&#xff0c;而是將處理器、內…

linux虛擬機基礎-磁盤擴容詳細版本模擬實驗

擴容實驗參考上一篇博客&#xff1a; https://blog.csdn.net/wenxiaocsdn/article/details/141932877?spm1001.2014.3001.5502 LVM基礎知識附錄紅帽官方文檔 配置和管理邏輯卷 | Red Hat Enterprise Linux | 8 | Red Hat Documentation LVM邏輯結構圖 LVM 管理命令速查表&…

hbase高可用部署

要實現HBase集群的高可用部署&#xff08;High Availability, HA&#xff09;&#xff0c;核心在于消除單點故障&#xff08;特別是HMaster節點&#xff09;&#xff0c;并確保數據冗余和服務自動恢復。以下是、關鍵步驟和配置要點&#xff1a; 一、核心配置步驟? ?1.1 啟用…

STM32F103ZET6開發板【項目工程創建】+具體實現步驟流程

硬件介紹 芯片為STM32F103ZET6 STM32F103 資源簡介 STM32 的優異性 1&#xff0c;超低的價格。8 位機的價格&#xff0c;32 位機的性能&#xff0c;是 STM32 最大的優勢。 2&#xff0c;超多的外設。STM32 擁有包括&#xff1a;FMC、TIMER、SPI、IIC、USB、CAN、IIS、SDIO、…

CyberGlove觸覺反饋手套遙操作機器人靈巧手解決方案

CyberGlove觸覺反饋手套確實可以實時捕捉運動信號和觸覺反饋&#xff0c;并將其重新定位到人形機器人上。CyberGlove觸覺反饋手套遙操作機器人是通過手套上的傳感器捕捉手部動作&#xff0c;將信號傳輸給機器人&#xff0c;同時接收機器人反饋的觸覺信息&#xff0c;實現遠程操…

[C#]C# winform部署yolov13目標檢測的onnx模型

yolov13官方框架&#xff1a;github.com/iMoonLab/yolov13/releases/tag/yolov13 【測試環境】 vs2019 netframework4.7.2 opencvsharp4.8.0 onnxruntime1.16.3 【效果展示】 【調用代碼】 using System; using System.Collections.Generic; using System.ComponentMode…

創客匠人 AI 賦能:創始人 IP 打造的效率革命與信任重構

在注意力經濟時代&#xff0c;創始人 IP 面臨內容生產效率與信任構建的雙重挑戰。創客匠人 2025 年戰略升級為 “IP 變現整體解決方案服務商”&#xff0c;其推出的 AI 銷售信、免訓數字人、智能客服三大工具&#xff0c;正通過技術重構破解行業痛點&#xff0c;為知識變現開辟…

飛輪儲能VSG控制策略輔助雙饋風機一次調頻的仿真模型研究

以下是為您撰寫的《飛輪儲能VSG控制策略輔助雙饋風機一次調頻的仿真模型研究》技術報告,包含完整的理論分析、控制策略設計及MATLAB/Simulink仿真實現細節: 飛輪儲能VSG控制策略輔助雙饋風機一次調頻的仿真模型研究 摘要 針對雙饋感應發電機(DFIG)參與電網一次調頻時存在…

臨床開發計劃:從實驗室到市場的戰略藍圖

一、臨床開發計劃概述 1.1 定義與重要性 1.1.1 CDP核心定義 臨床開發計劃(CDP)是藥物、生物制品或醫療器械從實驗室走向市場的核心路線圖,詳細規劃臨床研究及其策略、時間表和資源需求,以滿足監管機構審批要求。 1.1.2 指導意義 CDP為開發團隊提供清晰指引,指導資源規劃…

【大模型實戰】微調Qwen2.5 VL模型,增強目標檢測任務。

文章目錄 制作數據集使用微調的模型制作數據集 制作數據集 這個章節將詳細解析一個將Labelme標注數據集轉換為Qwen2.5-VL模型訓練格式的Python腳本。該工具實現了圖像大小調整、邊界框坐標轉換和數據格式標準化等功能。生成適用Qwen2.5-VL的數據集。 核心功能概述 圖像處理&a…

【python實用小腳本-118】基于Flask的用戶認證系統:app.py、forms.py與user.py解析

在當今的網絡應用中&#xff0c;用戶認證是一個不可或缺的功能。無論是社交平臺、電商平臺還是企業管理系統&#xff0c;都需要確保只有授權用戶才能訪問特定的資源。本文將詳細介紹一個基于 Flask 框架的用戶認證系統&#xff0c;該系統由三個主要文件組成&#xff1a;app.py、…

phpstudy apache偽靜態.htaccess文件置空丟失問題解決

phpstudy apache偽靜態.htaccess文件置空丟失 在使用phpstudy本地部署項目的時候&#xff0c;創建網站-根目錄選擇public等運行目錄&#xff0c;并且點擊確認后&#xff0c;會碰到原本項目中的apache偽靜態.htaccess文件被置空丟失的問題&#xff0c;導致項目無法正常訪問。 解…

【thinkphp5】Session和Cache記錄微信accesstoken

記錄一個項目實際遇到的坑&#xff0c;不要把token存放在session&#xff0c;要存在在cache里面&#xff01;&#xff01; 因為Session并不能設置expire過期時間&#xff0c;Session::set()方法第三個參數是作用域&#xff0c;而非過期時間&#xff01;&#xff01;&#xff0…

網絡協議完全指南:從HTTP長短連接到TCP-UDP的深度對話

&#x1f310; 網絡協議完全指南&#xff1a;從HTTP長短連接到TCP-UDP的深度對話 本文采用對話形式&#xff0c;通過小李和小王的問答&#xff0c;深入淺出地講解網絡協議、長短連接等核心概念&#xff0c;幫助讀者建立完整的網絡知識體系。 引言 在Java后端開發中&#xff0c…

04-StarRocks集群運維FAQ

StarRocks集群運維FAQ 概述 本文檔整理了StarRocks集群運維過程中常見的問題和解決方案,涵蓋了集群管理、節點維護、監控告警、故障處理等各個方面,幫助運維人員高效管理StarRocks集群。 集群管理FAQ Q1: 如何查看集群狀態? A: 集群狀態查看方法: 1. 查看FE節點狀態 …

通過Prompt提示構建思維鏈

《DEEPSEEK原生應用與智能體開發實踐 王曉華 書籍 圖書》【摘要 書評 試讀】- 京東圖書 思維鏈技術開啟了人工智能通向人類智能的嶄新路徑。它讓模型不再僅僅是機械地執行指令&#xff0c;而是開始具備類似人類的思考方式&#xff0c;能夠理解問題的本質&#xff0c;進行深層次…