SQLite数据库调用系统程序的实现与应用
2016-06-06陈刚侯晓荣
陈刚++侯晓荣

摘要:该文对SQLite数据库源码进行了分析、修改和重新编译,为SQLite数据库增加了自定义的内置函数,实现了SQLite对系统程序的调用。基于此,提出采用SQLite数据库对数据进行检测并调用系统中的程序对检测的问题进行处理,适用于嵌入式监控系统中的数据检测和报警问题。该方法利用了数据库对数据进行检测和处理,相比编程的方法,减少了程序员的工作量,方便了大批量数据的管理。
关键词:嵌入式;SQLite;数据库;SQLite;内置函数;监控系统
中图分类号:TP311 文献标识码:A 文章编号:1009-3044(2016)06-0001-02
Implementation and Application of SQLite Calling System Program
CHEN Gang, HOU Xiao-rong
(School of Energy Science and Engineering, University of Electronic Science and Technology of China, Chengdu 611731, China)
Abstract: In this paper,the source code of SQLite is analyzed, modified and recompiled. By this way, a new custom built-in function is added to the SQLite, which enable the SQLite database system to call the system programs. Based on this new function, this paper proposes to use SQLite database for data detection and invoking programs to dealing with detected problems, which is suitable for the data detection and alarm handling problems in the embedded monitoring system. This method utilizes the database technology to detect data and handle alarms, which reduces the workload of the programmer and facilitates large amounts of data management compared with the programming method.
Key words: Embedded System ; SQLite; Database; Built-in Function; Monitoring System
1 引言
在嵌入式数据采集与监控系统中,需要对数据进行定时检测,当数据出现异常时,调用程序进行相应的处理。比如,对一个温度数据采集与监控系统而言,当检测到温度过高时,需要调用系统控制程序降低温度,或者调用程序触发相关告警装置,提醒工作人员处理。一般的,监控系统中数据的检测与处理,都是通过编写程序完成的。但是,当数据量非常大的时候,程序的数据判断和处理工作会非常多,代码量巨大,不方便程序的开发和管理。
针对以上问题,本文通过对SQLite源码进行修改和重新编译,实现了SQLite数据库对系统程序的调用。基于此,提出通过SQLite数据库解决监控系统中的数据检测和处理问题:如图1所示,利用SQLite的触发器对存储的数据进行判断,当数据异常时,触发相关程序进行处理。该方法通过设计数据库触发器检测和处理数据,相比编程的方法,不用编写繁杂的判断处理代码,可以方便大量数据的监控管理。……
