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

6、监测数据采集物联网应用开发步骤(5.2)

  1. 监测数据采集物联网应用开发步骤(5.1)

包含4个类数据库连接(com.zxy.db_Self.ConnectionPool_Self.py)、数据库操作类(com.zxy.db_Self.Db_Common_Self.py)、数据库管理类(com.zxy.db_Self.DBManager_Self.py)、数据库连接池类(com.zxy.db_Self.PooledConnection_Self.py)

据库连接(com.zxy.db_Self.ConnectionPool_Self.py

#! python3
# -*- coding: utf-8 -
'''
Created on 2023年08月28日
@author: zxyong 13738196011
'''import sqlite3,time,mysql.connector,threading
from com.zxy.z_debug import z_debug
from com.zxy.db_Self.PooledConnection_Self import PooledConnection_Self#监测数据采集物联网应用--数据库连接
class ConnectionPool_Self(z_debug):attJdbcDriver = ""attDbUrl = ""attDbUsername = ""attDbPassword = ""attInitialConnections = 5attIncrementalConnections = 2attMaxConnections = 10attPooledConnection_Selfs = []def __init__(self, inputJdbcDriver, inputDbUrl, inputDbUsername, inputDbPassword): self.attJdbcDriver = inputJdbcDriverif inputJdbcDriver == "org.sqlite.JDBC":self.attInitialConnections = 2self.attMaxConnections = 5self.attDbUrl = inputDbUrlself.attDbUsername = inputDbUsernameself.attDbPassword = inputDbPasswordtry:self.createPool()except Exception as e:if str(type(self)) == "<class 'type'>":self.debug_in(self,repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息else:self.debug_in(repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息finally:passdef createPool(self):if len(self.attPooledConnection_Selfs) == 0:lock = threading.Lock()if lock.acquire():self.createConnections(self.attInitialConnections) if str(type(self)) == "<class 'type'>":self.debug_in(self,"myself db create pool")#打印异常信息else:self.debug_in("myself db create pool")#打印异常信息lock.release()def createConnections(self, inputNumConnections):if self.attMaxConnections > 0 and len(self.attPooledConnection_Selfs) >= self.attMaxConnections:            if str(type(self)) == "<class 'type'>":self.debug_in(self,"myself db connections is max")#打印异常信息else:self.debug_in("myself db connections is max")#打印异常信息self.findFreeConnection()for iIndex in range(1,inputNumConnections):try:temCon = self.newConnection()temPolCon = PooledConnection_Self(temCon)self.attPooledConnection_Selfs.append(temPolCon)            except Exception as e:if str(type(self)) == "<class 'type'>":self.debug_in(self,repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息else:self.debug_in(repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息def newConnection(self):        if self.attJdbcDriver == "org.sqlite.JDBC":temConn = sqlite3.connect(self.attDbUrl,check_same_thread = False)return temConnelif self.attJdbcDriver == "com.mysql.jdbc.Driver":try:temConn = mysql.connector.Connect(host=self.attDbUrl.split(":")[0],user=self.attDbUsername,db=self.attDbUrl.split(":")[2],passwd=self.attDbPassword,port=self.attDbUrl.split(":")[1])return temConnexcept Exception as e:if str(type(self)) == "<class 'type'>":self.debug_in(self,repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息else:self.debug_in(repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息else:return Nonedef getConnection(self):temReturnResult = Nonelock = threading.Lock()if lock.acquire():if len(self.attPooledConnection_Selfs) == 0:return Noneelse:temReturnResult = self.getFreeConnection()    while self.attPooledConnection_Selfs is None:time.sleep(0.2)temReturnResult = self.getFreeConnection()lock.release()return temReturnResultdef getFreeConnection(self):temConn_self = self.findFreeConnection()if temConn_self is None:self.createConnections(self.attIncrementalConnections)temConn_self = self.findFreeConnection()if temConn_self is None:return Nonereturn temConn_selfdef findFreeConnection(self):temPc = Nonewhile temPc is None:for i in range(len(self.attPooledConnection_Selfs)):temPc = self.attPooledConnection_Selfs[i]if temPc.attBusy == False or temPc.attConnection is None:temPc.attBusy = Truetry:if temPc.attConnection is None :temPc.attConnection = self.newConnection()                        except Exception as e:del self.attPooledConnection_Selfs[i]i = i - 1if str(type(self)) == "<class 'type'>":self.debug_in(self,repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息else:self.debug_in(repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息continuebreakif temPc.attConnection is not None:breakelse:time.sleep(0.5)return temPcdef closeConnection(self,inputConn):try:if str(type(self)) == "<class 'type'>":self.debug_in(self,"the myself close db")#打印异常信息else:self.debug_in("the myself close db")#打印异常信息inputConn.close()except Exception as e:if str(type(self)) == "<class 'type'>":self.debug_in(self,repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息else:self.debug_in(repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息def returnConnection(self,inputConn):if len(self.attPooledConnection_Selfs) == 0:if str(type(self)) == "<class 'type'>":self.debug_in(self,"myself db  returnConnection!")#打印异常信息else:self.debug_in("myself db  returnConnection!")#打印异常信息return Nonefor i in range(len(self.attPooledConnection_Selfs)):temPConn = self.attPooledConnection_Selfs[i]            if temPConn.attConnection == inputConn and temPConn.attBusy:temPConn.attBusy = FalseBreak

数据库操作类(com.zxy.db_Self.Db_Common_Self.py

#! python3
# -*- coding: utf-8 -
'''
Created on 2023年08月28日
@author: zxyong 13738196011
'''from com.zxy.adminlog.UsAdmin_Log import UsAdmin_Log
from com.zxy.common import Com_Para
from com.zxy.db_Self.DBManager_Self import DBManager_Self
from com.zxy.z_debug import z_debug#监测数据采集物联网应用--数据库操作
class Db_Common_Self(z_debug):    attSqlException = ""attRs_out = NoneattConn_a = NoneattColumnNames = []def __init__(self):passdef Common_SqlNoCommit(self, inputStrSql):temRs = Nonetry:temDs = DBManager_Self()self.attConn_a = temDs.getConnection()if str(self.attConn_a.attConnection).find("sqlite3.Connection") != -1:Com_Para.Dblock1.acquire()temRs = self.attConn_a.executeQueryNoCommit(inputStrSql)         except Exception as e:            temLog = ""if str(type(self)) == "<class 'type'>":temLog = self.debug_info(self)+inputStrSql+"==>"+repr(e)self.debug_in(self,inputStrSql+"==>"+repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息else:temLog = self.debug_info()+inputStrSql+"==>"+repr(e)self.debug_in(inputStrSql+"==>"+repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息uL = UsAdmin_Log(Com_Para.ApplicationPath, temLog)uL.WriteLog()finally:temDs.returnConnection(self.attConn_a.attConnection)self.Close_Conn()if str(self.attConn_a.attConnection).find("sqlite3.Connection") != -1:Com_Para.Dblock1.release()return temRsdef Common_Sql(self, inputStrSql):temRs = Nonetry:temDs = DBManager_Self()self.attConn_a = temDs.getConnection()temRs = self.attConn_a.executeQuery(inputStrSql) self.attColumnNames = self.attConn_a.attColumnNames          except Exception as e:        temLog = ""if str(type(self)) == "<class 'type'>":temLog = self.debug_info(self)+inputStrSql+"==>"+repr(e)self.debug_in(self,inputStrSql+"==>"+repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息else:temLog = self.debug_info()+inputStrSql+"==>"+repr(e)self.debug_in(inputStrSql+"==>"+repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息uL = UsAdmin_Log(Com_Para.ApplicationPath, temLog)uL.WriteLog()finally:temDs.returnConnection(self.attConn_a.attConnection)self.Close_Conn()return temRsdef CommonExec_SqlRowID(self, inputStrSql):temIResult = -1try:temDs = DBManager_Self()self.attConn_a = temDs.getConnection()if str(self.attConn_a.attConnection).find("sqlite3.Connection") != -1:Com_Para.Dblock1.acquire()temIResult = self.attConn_a.executeUpdateRowID(inputStrSql)         except Exception as e:        temLog = ""if str(type(self)) == "<class 'type'>":temLog = self.debug_info(self)+inputStrSql+"==>"+repr(e)self.debug_in(self,inputStrSql+"==>"+repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息else:temLog = self.debug_info()+inputStrSql+"==>"+repr(e)self.debug_in(inputStrSql+"==>"+repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息uL = UsAdmin_Log(Com_Para.ApplicationPath, temLog)uL.WriteLog()temIResult = -1finally:temDs.returnConnection(self.attConn_a.attConnection)self.Close_Conn()if str(self.attConn_a.attConnection).find("sqlite3.Connection") != -1:Com_Para.Dblock1.release()return temIResultdef CommonExec_Sql(self, inputStrSql):temIResult = -1try:temDs = DBManager_Self()self.attConn_a = temDs.getConnection()if str(self.attConn_a.attConnection).find("sqlite3.Connection") != -1:Com_Para.Dblock1.acquire()temIResult = self.attConn_a.executeUpdate(inputStrSql)         except Exception as e:temLog = ""if str(type(self)) == "<class 'type'>":temLog = self.debug_info(self)+inputStrSql+"==>"+repr(e)self.debug_in(self,inputStrSql+"==>"+repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息else:temLog = self.debug_info()+inputStrSql+"==>"+repr(e)self.debug_in(inputStrSql+"==>"+repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息uL = UsAdmin_Log(Com_Para.ApplicationPath, temLog)uL.WriteLog()temIResult = -1finally:temDs.returnConnection(self.attConn_a.attConnection)self.Close_Conn()if str(self.attConn_a.attConnection).find("sqlite3.Connection") != -1:Com_Para.Dblock1.release()return temIResult    #     ProName 存储过程名 Parameters输入参数 ParamTypes参数类型String Int float Date
#     ParamOutName输出参数名 ParamOutType输出参数类型def Common_Sql_Proc(self,inputProName, inputParameters, inputParamTypes, inputParamOutName, inputParamOutType, inputTrn):try:    temDs = DBManager_Self()self.attConn_a = temDs.getConnection()        if str(self.attConn_a.attConnection).find("sqlite3.Connection") != -1:Com_Para.Dblock1.acquire()if inputTrn.attINF_TYPE == "1":self.attRs_out = self.attConn_a.ParamExecuteQuery(inputProName,inputParameters,inputParamTypes,inputParamOutName,inputParamOutType)else:self.attRs_out = self.attConn_a.ParamExecuteQuery(inputProName,inputParameters,inputParamTypes,inputParamOutName,inputParamOutType,inputTrn.attINF_EN_SQL)self.attColumnNames = self.attConn_a.attColumnNamesexcept Exception as e:self.attSqlException = "数据库操作出错请查看程序错误日志文件:" + inputProName + " "+ repr(e)        temLog = ""if str(type(self)) == "<class 'type'>":temLog = self.debug_info(self)+inputProName+"==>"+repr(e)self.debug_in(self,inputProName+"==>"+repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息else:temLog = self.debug_info()+inputProName+"==>"+repr(e)self.debug_in(inputProName+"==>"+repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息uL = UsAdmin_Log(Com_Para.ApplicationPath, temLog)uL.WriteLog()finally:temDs.returnConnection(self.attConn_a.attConnection)self.Close_Conn()if str(self.attConn_a.attConnection).find("sqlite3.Connection") != -1:Com_Para.Dblock1.release()return self.attRs_outdef Close_Conn(self):if not self.attConn_a.attConnection is None:pass

数据库管理类(com.zxy.db_Self.DBManager_Self.py

#! python3
# -*- coding: utf-8 -
'''
Created on 2023年08月28日
@author: zxyong 13738196011
'''from com.zxy.common import Com_Para
from com.zxy.common.DbConfigSelf import DbConfigSelf
from com.zxy.db_Self.ConnectionPool_Self import ConnectionPool_Self
from com.zxy.z_debug import z_debug#监测数据采集物联网应用--数据库管理
class DBManager_Self(z_debug):attConn = NoneattConnectionPool = Nonedef __init__(self):if Com_Para.url == "":DbConfigSelf.GetDbConfigSelfNew()self.attConnectionPool = ConnectionPool_Self(Com_Para.driverClassName,Com_Para.url,Com_Para.username,Com_Para.password)try:self.attConnectionPool.createPool()except Exception as e:if str(type(self)) == "<class 'type'>":self.debug_in(self,repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息else:self.debug_in(repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息finally:passdef getConnection(self):try:self.attConn = self.attConnectionPool.getConnection()except Exception as e:if str(type(self)) == "<class 'type'>":self.debug_in(self,repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息else:self.debug_in(repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息finally:return self.attConndef returnConnection(self,inputConn):return self.attConnectionPool.returnConnection(inputConn)@staticmethoddef closeConnectionPoolTimeOut(self):try:self.attConnectionPool.closeConnectionPoolTimeOut()except Exception as e:if str(type(self)) == "<class 'type'>":self.debug_in(self,repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息else:self.debug_in(repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息finally:Pass

数据库连接池类(com.zxy.db_Self.PooledConnection_Self.py

#! python3
# -*- coding: utf-8 -
'''
Created on 2023年08月28日
@author: zxyong 13738196011
'''from urllib.parse import unquotefrom com.zxy.adminlog.UsAdmin_Log import UsAdmin_Log
from com.zxy.common import Com_Para
from com.zxy.common.Com_Fun import Com_Fun
from com.zxy.z_debug import z_debug#监测数据采集物联网应用--数据库连接池
class PooledConnection_Self(z_debug):attUpdtime = 0attB_nocursor = TrueattConnection = NoneattBusy = FalseattColumnNames = []attlastrowid = -1def __init__(self, inputConn):self.attB_nocursor = Trueself.attConnection = inputConnself.attUpdtime = Com_Fun.getTimeLong()def executeQueryNoCommit(self, inputSql):temCursor = NonetemValues = Nonetry:self.attUpdtime = Com_Fun.getTimeLong()        # 建立cursortemCursor = self.attConnection.cursor()# 执行sql selecttemCursor.execute(inputSql)# 利用featchall获取数据temValues = temCursor.fetchall()self.attColumnNames = temCursor.descriptionself.attConnection.commit()except Exception as e:temLog = ""if str(type(self)) == "<class 'type'>":temLog = self.debug_info(self)+inputSql+"==>"+repr(e)self.debug_in(self,inputSql+"==>"+repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息else:temLog = self.debug_info()+inputSql+"==>"+repr(e)self.debug_in(inputSql+"==>"+repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息uL = UsAdmin_Log(Com_Para.ApplicationPath, temLog)uL.WriteLog()finally:if not temCursor is None:temCursor.close()return temValuesdef executeQuery(self, inputSql):temCursor = NonetemValues = Nonetry:self.attUpdtime = Com_Fun.getTimeLong()        # 建立cursortemCursor = self.attConnection.cursor()# 执行sql selecttemCursor.execute(inputSql)# 利用featchall获取数据temValues = temCursor.fetchall()self.attColumnNames = temCursor.descriptionif inputSql.lower().find("insert into") == 0 or inputSql.lower().find("update ") == 0 or inputSql.lower().find("delete ") == 0:self.attConnection.commit()except Exception as e:temLog = ""if str(type(self)) == "<class 'type'>":temLog = self.debug_info(self)+inputSql+"==>"+repr(e)self.debug_in(self,inputSql+"==>"+repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息else:temLog = self.debug_info()+inputSql+"==>"+repr(e)self.debug_in(inputSql+"==>"+repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息uL = UsAdmin_Log(Com_Para.ApplicationPath, temLog)uL.WriteLog()finally:if not temCursor is None:temCursor.close()return temValuesdef executeUpdateRowID(self, inputSql):temResult = -1temCursor = Nonetry:self.attUpdtime = Com_Fun.getTimeLong()        # 建立cursortemCursor = self.attConnection.cursor()# 执行sql insert update delete ttemCursor.execute(inputSql)temResult = temCursor.lastrowidself.attConnection.commit()except Exception as e:temLog = ""if str(type(self)) == "<class 'type'>":temLog = self.debug_info(self)+inputSql+"==>"+repr(e)self.debug_in(self,inputSql+"==>"+repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息else:temLog = self.debug_info()+inputSql+"==>"+repr(e)self.debug_in(inputSql+"==>"+repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息uL = UsAdmin_Log(Com_Para.ApplicationPath, temLog)uL.WriteLog()finally:if not temCursor:temCursor.close()return temResultdef executeUpdate(self, inputSql):temResult = -1temCursor = Nonetry:self.attUpdtime = Com_Fun.getTimeLong()        # 建立cursortemCursor = self.attConnection.cursor()# 执行sql insert update delete ttemCursor.execute(inputSql)temResult = temCursor.rowcountself.attConnection.commit()except Exception as e:temLog = ""if str(type(self)) == "<class 'type'>":temLog = self.debug_info(self)+inputSql+"==>"+repr(e)self.debug_in(self,inputSql+"==>"+repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息else:temLog = self.debug_info()+inputSql+"==>"+repr(e)self.debug_in(inputSql+"==>"+repr(e)+"=>"+str(e.__traceback__.tb_lineno))#打印异常信息uL = UsAdmin_Log(Com_Para.ApplicationPath, temLog)uL.WriteLog()finally:if not temCursor:temCursor.close()return temResultdef ParamExecuteQuery(self,inputProName, inputParameters, inputParamTypes, inputParamOutName, inputParamOutType, inputStrSql):self.attUpdtime = Com_Fun.getTimeLong()temValues = None# 建立cursortemCursor = self.attConnection.cursor()if len(inputParameters) == len(inputParamTypes) and len(inputParamOutName) == len(inputParamOutType):i = 0for temParamTypes in inputParamTypes:if temParamTypes == "LIST":j = 0temStr_V = ""for iIn in temParamTypes.split(","):if j != 0:temStr_V += ","temStr_V += "?"j += 1                    inputStrSql = inputStrSql.replace("@\\?",temStr_V,1)if temParamTypes.upper() == "STRING":inputParameters[i] = inputParameters[i]#Com_Fun.py_urldecode(inputParameters[i])#unquote(inputParameters[i],Com_Para.U_CODE)passelif temParamTypes.upper() == "INT":inputParameters[i] = int(inputParameters[i])passelif temParamTypes.upper() == "FLOAT":inputParameters[i] = float(inputParameters[i])passelif temParamTypes.upper() == "DATE":inputParameters[i] = unquote(inputParameters[i].replace("+"," "),Com_Para.U_CODE)passelif temParamTypes.upper() == "LIST":passelif temParamTypes.upper() == "LIKESTRING":inputParameters[i] = unquote(inputParameters[i],Com_Para.U_CODE)passi += 1if inputStrSql.upper().strip().find("INSERT INTO") == 0 or inputStrSql.upper().strip().find("UPDATE") == 0:# 执行sql selectiCount = temCursor.execute(inputStrSql,inputParameters)self.attlastrowid = temCursor.lastrowidif iCount.rowcount != -1:# 执行sql insert update delete ttemCursor.execute("select '1' as 's_result','成功,"+str(iCount.rowcount)+"' as 'error_desc'")else:temCursor.execute("select '0' as 's_result','失败' as 'error_desc'")# 利用featchall获取数据temValues = temCursor.fetchall()self.attColumnNames = temCursor.descriptionself.attConnection.commit()elif inputStrSql.upper().strip().find("DELETE") == 0:if inputStrSql.upper().strip().find(";") != -1:iCount = Nonefor strSqls in inputStrSql.split(";"):             # 执行多个sqliCount = temCursor.execute(strSqls)if iCount.rowcount != -1:# 执行sql insert update delete ttemCursor.execute("select '1' as 's_result','成功' as 'error_desc'")else:temCursor.execute("select '0' as 's_result','失败' as 'error_desc'")# 利用featchall获取数据temValues = temCursor.fetchall()self.attColumnNames = temCursor.descriptionself.attConnection.commit()else:# 执行sql selectiCount = temCursor.execute(inputStrSql,inputParameters)if iCount.rowcount != -1:# 执行sql insert update delete ttemCursor.execute("select '1' as 's_result','成功' as 'error_desc'")else:temCursor.execute("select '0' as 's_result','失败' as 'error_desc'")# 利用featchall获取数据temValues = temCursor.fetchall()self.attColumnNames = temCursor.descriptionself.attConnection.commit()elif inputStrSql.upper().strip().find("SELECT") == 0:iCount = temCursor.execute(inputStrSql,inputParameters)# 利用featchall获取数据temValues = temCursor.fetchall()self.attColumnNames = temCursor.descriptionself.attConnection.commit()return temValues
  1. 监测数据采集物联网应用开发步骤(5.3)

相关文章:

6、监测数据采集物联网应用开发步骤(5.2)

监测数据采集物联网应用开发步骤(5.1) 包含4个类数据库连接&#xff08;com.zxy.db_Self.ConnectionPool_Self.py&#xff09;、数据库操作类&#xff08;com.zxy.db_Self.Db_Common_Self.py&#xff09;、数据库管理类&#xff08;com.zxy.db_Self.DBManager_Self.py&#xf…...

解释 Git 的基本概念和使用方式

该文为AI自动生成&#xff0c;InsCode AI 创作助手 Git 是一种版本控制工具&#xff0c;用于跟踪代码或文件的更改历史记录。以下是 Git 的基本概念和使用方式&#xff1a; 仓库 (Repository)&#xff1a;仓库是一个存储项目代码和历史记录的地方&#xff0c;可以在本地或远程…...

不同ubuntu系统下的不同ros系统可以互相通讯吗

可以的,不同版本的Ubuntu系统和ROS版本的机器仍然可以实现ROS节点之间的通信。 主要的原因有:1. ROS节点间通信是通过ROS master实现的。不同机器上的ROS节点都可以连接到同一个ROS master,从而实现通信。 2. ROS消息系统可以兼容不同的ROS版本。即使节点使用的ROS版本不同,也…...

数学建模-模型详解(2)

微分模型 当谈到微分模型时&#xff0c;通常指的是使用微分方程来描述某个系统的动态行为。微分方程是描述变量之间变化率的数学方程。微分模型可以用于解决各种实际问题&#xff0c;例如物理学、工程学、生物学等领域。 微分模型可以分为两类&#xff1a;常微分方程和偏微分…...

IT运维:使用数据分析平台监控DELL服务器

概述 在企业日常运维中&#xff0c;我们有着大量的服务器设备&#xff0c;设备故障一般可以通过常用的监控软件实现自动告警&#xff0c;但如果在管理运维中我们要做的不仅仅是发现故障&#xff0c;处理硬件故障&#xff0c;我们还需要进一步的了解&#xff0c;今年一共出现了多…...

Spring Cloud Alibaba-Sentinel规则

1 流控规则 流量控制&#xff0c;其原理是监控应用流量的QPS(每秒查询率) 或并发线程数等指标&#xff0c;当达到指定的阈值时 对流量进行控制&#xff0c;以避免被瞬时的流量高峰冲垮&#xff0c;从而保障应用的高可用性。 第1步: 点击簇点链路&#xff0c;我们就可以看到访…...

go http-proxy

我们这里主要讲使用HTTP&#xff0f;1.1协议中的CONNECT方法建立起来的隧道连接&#xff0c;实现的HTTP Proxy。这种代理的好处就是不用知道客户端请求的数据&#xff0c;只需要原封不动的转发就可以了&#xff0c;对于处理HTTPS的请求就非常方便了&#xff0c;不用解析他的内容…...

用变压器实现德-英语言翻译【01/8】:嵌入层

一、说明 本文是“用变压器实现德-英语言翻译”系列的第一篇文章。它引入了小规模的嵌入来建立感知系统。接下来是嵌入层的变压器使用。下面简要概述了每种方法&#xff0c;然后是德语到英语的翻译。 二、技术背景 嵌入层的目标是使模型能够详细了解单词、标记或其他输入之间的…...

【vue3.0中ref与reactive的区别及使用】

什么是ref与reactive ref与reactive都是Vue3.0中新增的API&#xff0c;用于响应式数据的处理。 1. ref ref是一个函数&#xff0c;可以用于将一个普通的数据类型转换成响应式数据。ref返回一个包含value属性的对象&#xff0c;通过修改value属性的值&#xff0c;可以触发组件…...

计算机竞赛 基于情感分析的网络舆情热点分析系统

文章目录 0 前言1 课题背景2 数据处理3 文本情感分析3.1 情感分析-词库搭建3.2 文本情感分析实现3.3 建立情感倾向性分析模型 4 数据可视化工具4.1 django框架介绍4.2 ECharts 5 Django使用echarts进行可视化展示5.1 修改setting.py连接mysql数据库5.2 导入数据5.3 使用echarts…...

C++ 动态分配内存|动态数组

int** arr new int* [n]; for (int i 0; i < n; i) {arr[i] new int[2]; } 以上代码是用C动态分配了一个二维数组arr&#xff0c;其中arr是一个指向int指针的指针&#xff0c;n是一个整数。代码的目的是创建一个包含n个大小为2的整数数组的二维数组。 首先&#xff0c;…...

React Diff算法原理

文章目录 前言Diff算法原理 前言 &#x1f449;点此&#xff08;想要了解Diff算法&#xff09; Diff算法原理 React Diff算法是React用于更新虚拟DOM树的一种算法。它通过比较新旧虚拟DOM树的差异&#xff0c;然后只对有差异的部分进行更新&#xff0c;从而提高性能。 Reac…...

查局域网所有占用IP

查局域网所有占用IP 按&#xff1a;winr 出现下面界面&#xff0c;在文本框中输入 cmd 按确定即可出现cmd命令界面 在cmd命令窗口输入你想要ping的网段&#xff0c;下面192.168.20.%i即为你想要ping的网段&#xff0c;%i代表0-255 for /L %i IN (1,1,254) DO ping -w 1 -n 1…...

【MySQL】引擎类型

与其他DBMS一样&#xff0c;MySQL有一个 具体管理和处理数据的内部引擎 。在使用create table语句时&#xff0c;该引擎具体创建表&#xff0c;而在使用select或进行其他数据库处理时&#xff0c;该引擎在内部处理你的请求。多数时候&#xff0c;引擎都隐藏在DBMS内&#xff0…...

springMVC之HttpMessageConverter

文章目录 前言一、RequestBody二、RequestEntity三、ResponseBody四、SpringMVC处理json五、SpringMVC处理ajax六、RestController注解七、ResponseEntity总结 前言 HttpMessageConverter&#xff0c;报文信息转换器&#xff0c;将请求报文转换为Java对象&#xff0c;或将Java…...

计算机网络aaaaaaa

差错检测 在一段时间内&#xff0c;传输错误的比特占所传输比特总数的比率称为误码率BER(Bit Error Rate) 11111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111…...

pdf.js构建时,报Cannot read property ‘createChildCompiler‘ of undefined #177的解决方法

在本地和CI工具进行构建时&#xff0c;报如下错误。 Cannot read property createChildCompiler of undefined #177解决方法&#xff1a; 找到vue.config.js&#xff0c;在 module.exports {parallel: false, //新增的一行chainWebpack(config) {....config.module.rule(&…...

Spring Boot(Vue3+ElementPlus+Axios+MyBatisPlus+Spring Boot 前后端分离)【六】

&#x1f600;前言 本篇博文是关于Spring Boot(Vue3ElementPlusAxiosMyBatisPlusSpring Boot 前后端分离)【六】&#xff0c;希望你能够喜欢 &#x1f3e0;个人主页&#xff1a;晨犀主页 &#x1f9d1;个人简介&#xff1a;大家好&#xff0c;我是晨犀&#xff0c;希望我的文章…...

idea配置注释模板

一、类的模板 设置里面依次找到图中标注的地方 填入 /** ${describe} author 填入你的名字 date ${YEAR}-${MONTH}-${DAY} ${TIME} version 1.0.0 */配置完成后&#xff0c;新创建的类就会自动生成类开头的注释 二、方法的注释模板 如图创建模板 步骤6中填入 *** $descrip…...

Unity编辑器扩展:提高效率与创造力的关键

Unity编辑器扩展&#xff1a;提高效率与创造力的关键 前言 一、理解Unity编辑器二、扩展Unity编辑器的意义三、扩展Unity编辑器的必要性四、Unity编辑器的扩展方式五、扩展Unity编辑器的步骤六、Unity编辑器扩展的应用案例七、总结 前言 Unity是一款广泛使用的游戏开发引擎&am…...

模型参数、模型存储精度、参数与显存

模型参数量衡量单位 M&#xff1a;百万&#xff08;Million&#xff09; B&#xff1a;十亿&#xff08;Billion&#xff09; 1 B 1000 M 1B 1000M 1B1000M 参数存储精度 模型参数是固定的&#xff0c;但是一个参数所表示多少字节不一定&#xff0c;需要看这个参数以什么…...

.Net框架,除了EF还有很多很多......

文章目录 1. 引言2. Dapper2.1 概述与设计原理2.2 核心功能与代码示例基本查询多映射查询存储过程调用 2.3 性能优化原理2.4 适用场景 3. NHibernate3.1 概述与架构设计3.2 映射配置示例Fluent映射XML映射 3.3 查询示例HQL查询Criteria APILINQ提供程序 3.4 高级特性3.5 适用场…...

聊聊 Pulsar:Producer 源码解析

一、前言 Apache Pulsar 是一个企业级的开源分布式消息传递平台&#xff0c;以其高性能、可扩展性和存储计算分离架构在消息队列和流处理领域独树一帜。在 Pulsar 的核心架构中&#xff0c;Producer&#xff08;生产者&#xff09; 是连接客户端应用与消息队列的第一步。生产者…...

使用van-uploader 的UI组件,结合vue2如何实现图片上传组件的封装

以下是基于 vant-ui&#xff08;适配 Vue2 版本 &#xff09;实现截图中照片上传预览、删除功能&#xff0c;并封装成可复用组件的完整代码&#xff0c;包含样式和逻辑实现&#xff0c;可直接在 Vue2 项目中使用&#xff1a; 1. 封装的图片上传组件 ImageUploader.vue <te…...

Rapidio门铃消息FIFO溢出机制

关于RapidIO门铃消息FIFO的溢出机制及其与中断抖动的关系&#xff0c;以下是深入解析&#xff1a; 门铃FIFO溢出的本质 在RapidIO系统中&#xff0c;门铃消息FIFO是硬件控制器内部的缓冲区&#xff0c;用于临时存储接收到的门铃消息&#xff08;Doorbell Message&#xff09;。…...

Linux --进程控制

本文从以下五个方面来初步认识进程控制&#xff1a; 目录 进程创建 进程终止 进程等待 进程替换 模拟实现一个微型shell 进程创建 在Linux系统中我们可以在一个进程使用系统调用fork()来创建子进程&#xff0c;创建出来的进程就是子进程&#xff0c;原来的进程为父进程。…...

智能AI电话机器人系统的识别能力现状与发展水平

一、引言 随着人工智能技术的飞速发展&#xff0c;AI电话机器人系统已经从简单的自动应答工具演变为具备复杂交互能力的智能助手。这类系统结合了语音识别、自然语言处理、情感计算和机器学习等多项前沿技术&#xff0c;在客户服务、营销推广、信息查询等领域发挥着越来越重要…...

Mysql8 忘记密码重置,以及问题解决

1.使用免密登录 找到配置MySQL文件&#xff0c;我的文件路径是/etc/mysql/my.cnf&#xff0c;有的人的是/etc/mysql/mysql.cnf 在里最后加入 skip-grant-tables重启MySQL服务 service mysql restartShutting down MySQL… SUCCESS! Starting MySQL… SUCCESS! 重启成功 2.登…...

Golang——9、反射和文件操作

反射和文件操作 1、反射1.1、reflect.TypeOf()获取任意值的类型对象1.2、reflect.ValueOf()1.3、结构体反射 2、文件操作2.1、os.Open()打开文件2.2、方式一&#xff1a;使用Read()读取文件2.3、方式二&#xff1a;bufio读取文件2.4、方式三&#xff1a;os.ReadFile读取2.5、写…...

在树莓派上添加音频输入设备的几种方法

在树莓派上添加音频输入设备可以通过以下步骤完成&#xff0c;具体方法取决于设备类型&#xff08;如USB麦克风、3.5mm接口麦克风或HDMI音频输入&#xff09;。以下是详细指南&#xff1a; 1. 连接音频输入设备 USB麦克风/声卡&#xff1a;直接插入树莓派的USB接口。3.5mm麦克…...