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

福田时代汽车官方网站网站建设需求分析的功能

福田时代汽车官方网站,网站建设需求分析的功能,上海中高风险地区,义乌小程序装修公司监测数据采集物联网应用开发步骤(4) Sqlite3数据库读写操作开发、异常信息统一处理类开发 本章节需要调用sqlite3及mysql-connector 安装sqlite3 Pip3 install sqlite3 安装mysql-connector pip3 install mysql-connector 验证是否安装成功,python中运行下列…
  1. 监测数据采集物联网应用开发步骤(4)

Sqlite3数据库读写操作开发、异常信息统一处理类开发

本章节需要调用sqlite3及mysql-connector

安装sqlite3

Pip3 install sqlite3

安装mysql-connector

pip3 install mysql-connector

验证是否安装成功,python中运行下列代码无异常则安装成功:

import sqlite3
import mysql.connector

在项目开发过程中各类异常信息try...except处理,该处理类将try ...except异常信息统一处理并日志文件输出,便于快速定位错误信息及代码位置;

异常信息日志打印格式

yyyy-MM-dd H:mm:ss=>异常的类名=>该类中调用出错的函数名==>其他异常信息

参考如下图:

创建异常信息统一处理类com.zxy.z_debug.py

调用方式参考:

from com.zxy.z_debug import z_debug
class ClassName(z_debug):

com.zxy.z_debug.py类

#! python3
# -*- coding: utf-8 -
'''
Created on 2023年08月28日
@author: zxyong 13738196011
'''import inspect,datetime
from com.zxy.adminlog.UsAdmin_Log import UsAdmin_Log
from com.zxy.common import Com_Para#监测数据采集物联网应用--异常信息统一处理
class z_debug(object):def __init__(self):passdef debug_in(self,inputMsg):excStr = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")+"=>"+str(self)+"=>"+self.__class__.__name__+"."+inspect.stack()[1][3]+"==>"+inputMsguL = UsAdmin_Log(Com_Para.ApplicationPath, excStr)uL.SaveFileDaySub("exception")print(excStr)def debug_info(self):excStr = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")+"=>"+str(self)+"=>"+self.__class__.__name__+"."+inspect.stack()[1][3]+"==>"uL = UsAdmin_Log(Com_Para.ApplicationPath, excStr)uL.SaveFileDaySub("exception_debug")return excStr

在多个线程中使用访问SQLite数据库,为避免多个线程之间的竞争。需要添加数据库线程锁机制以确保线程安全,若使用mysql数据库无需数据库线程锁机制。

com.zxy.common.Com_Para.py中添加如下内容

#数据库线程锁机制
Dblock1 = threading.Lock()
Dblock2 = threading.Lock()
Dblock3 = threading.Lock()
Dblock4 = threading.Lock()
#静态数据库配置文件路径
ACTIONPATH = "dbconfig.properties"
driverClassName = ""
url = ""
username = ""
password = ""
#是否桌面数据库 0:Mysql 1:sqlite3
IL_DB = 1
#数据库连接池初始数量 1:Sqlite3
incrementalConnections = 2
#数据库连接池最大数量
maxConnections = 10
port = -1
UserDebug = "0"

创建静态配置库数据库配置文件读写类com.zxy.common.DbConfigSelf.py

#! python3
# -*- coding: utf-8 -
'''
Created on 2023年08月28日
@author: zxyong 13738196011
'''import configparser
from com.zxy.common import Com_Para
from com.zxy.z_debug import z_debug#监测数据采集物联网应用--静态配置库数据库配置文件读写
class DbConfigSelf(z_debug):def __init__(self):pass@staticmethoddef GetDbConfigSelfNew():temPath = Com_Para.ApplicationPath + Com_Para.zxyPath + Com_Para.ACTIONPATHtemProp = configparser.ConfigParser()try:temProp.read(temPath)Com_Para.driverClassName = temProp.get("DB", "dataSource.driverClassName")            if Com_Para.driverClassName == "org.sqlite.JDBC" :Com_Para.incrementalConnections = 1Com_Para.maxConnections = 1Com_Para.IL_DB = 1temStrRem = temProp.get("DB","dataSource.url").replace("@",Com_Para.ApplicationPath + Com_Para.zxyPath)Com_Para.url = temStrRemelse:Com_Para.url = temProp.get("DB", "dataSource.url")Com_Para.username = temProp.get("DB", "dataSource.username")Com_Para.password = temProp.get("DB", "dataSource.password")Com_Para.port = temProp.getint("DB", "server.port")Com_Para.UserDebug = temProp.getint("DB", "userDebug")except Exception as e:print("GetDbConfigSelfNew:"+repr(e)+"=>"+str(e.__traceback__.tb_lineno))finally:Pass

创建静态配置库数据库配置文件dbconfig.properties

配置文件内容:

[DB]
dataSource.driverClassName=org.sqlite.JDBC
dataSource.url=@center_data.db
dataSource.username=
dataSource.password=server.port=9000
userDebug=0
  1. 监测数据采集物联网应用开发步骤(5.2)
http://www.yayakq.cn/news/790650/

相关文章:

  • 网站蓝色导航栏代码视频分享网站怎么做
  • 中国住房城乡和城乡建设部网站怎么查公司信息
  • 济南网站的优化wordpress做在线编辑图片大小
  • 微信运营技巧网站推广优化张店
  • 企业营销微网站建设网件路由器重置
  • 教学互动网站的设计电子商务网站建设与维护方法
  • c语言开发网站教程常州市住房和城乡建设局网站
  • 深圳门窗在哪里网站做推广wordpress内容页不显示
  • 站长工具大全集工厂订单外发代加工外发加工网
  • 58同城通辽做网站徐州专业网站制作
  • 个人网站建设网站排名优化产品网页设计公司
  • 汕头网站建设平台重庆轨道交通最新
  • 家居网站关键词怎么做临沂网站建设团队
  • 制作卖东西网站网站怎么做数据接口
  • 青岛网站制作公司网络35岁以后的程序员有多惨
  • 58同城一样的网站怎样建设如何做自己的网站商城站
  • 电商公司网站wordpress 36kr
  • 网站免费大全做外贸怎么进入国外的网站
  • 如何用网站做淘客网站好友邀请链接生成 php
  • asp网站伪静态教程如何创建html文件
  • 国外平台seo建站推广
  • 制作荧光字网站上海网站
  • 贵阳网站推广有几家网络推广专员
  • 深圳网站优化效果如何做企业网页
  • 青岛开发区网站大力推动卫生健康事业高质量发展
  • 教做甜品网站定制网站建设公司
  • 梅林做网站网络销售员每天做什么
  • 网站制作做网站淘宝电脑版登录网页入口
  • 网站建设一般字体多大赣州广播电视台
  • 登陆中国建设银行网站我的账户密码怎么就有了?怎么清除北京搜狗建网站的电话