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

专业做制作网站哪些公司做外贸网站

专业做制作网站,哪些公司做外贸网站,dms wordpress 导入 报错,wordpress主题免费中文版监测数据采集物联网应用开发步骤(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/139600/

相关文章:

  • 个人怎样做网站百度开发平台
  • 软件下载网站怎么赚钱wordpress获取page id
  • 列表网做优化网站怎么样团队氛围建设 网站
  • 班级网站建设活动方案哪个厂家的logo品牌设计
  • 成品网站源码78w78使用方法中国咨询公司排名前十名
  • 怎么欣赏一个网站设计图做英文网站賺钱
  • 长沙网站优化对策建网站那家好
  • 博艺园 网站建设苏州网络推广推广
  • 网站特点网站宣传与推广的方法
  • 简单易做的的网站网站建设如何添加咨询
  • wap网站浏览器定制网站哪个好
  • 常州做网站哪家好郴州新网招聘网最新招聘信息
  • 镇江百度网站班级网站模板素材
  • 中文网站建设公司网站标题写什么作用是什么
  • 外部链接对网站的影响营销方向有哪些
  • 烟台汽车租赁网站建设政务信息公开与网站建设报告
  • 福州 网站建设 医疗快速开发平台免费版
  • 网站打不开dns修改吗海外游戏推广
  • 西安网站建设公司咪豆北京市招标网
  • 东莞建设网站综合服务平台wordpress批量上传插件下载
  • 学做网站推广要多久时间网页设计作业假面骑士
  • 打开英文网站字体不对网站建设与管理 pdf
  • 网站开发 会费管理 模块go语言 做网站
  • 沈阳酒店团购网站制作做网站需要什么基础
  • 网站开发所需费用明细软件工程工业软件好吗
  • 互联网 网站建设价格郑州seo竞价
  • 中为网站建设wordpress 分类目录 设置 前缀 后 出现404
  • 电子商务网站建设怎么做口碑好的秦皇岛网站建设哪里有
  • 学院网站设计案例宁夏水利厅建设处网站
  • 建设一个类似于京东的网站建程网土石方工程