WO2017045491A1 - Method and system for upgrading sqlite3 embedded database - Google Patents

Method and system for upgrading sqlite3 embedded database Download PDF

Info

Publication number
WO2017045491A1
WO2017045491A1 PCT/CN2016/093106 CN2016093106W WO2017045491A1 WO 2017045491 A1 WO2017045491 A1 WO 2017045491A1 CN 2016093106 W CN2016093106 W CN 2016093106W WO 2017045491 A1 WO2017045491 A1 WO 2017045491A1
Authority
WO
WIPO (PCT)
Prior art keywords
database
upgrade
field
target
data stream
Prior art date
Application number
PCT/CN2016/093106
Other languages
French (fr)
Chinese (zh)
Inventor
范伟
张聪
Original Assignee
华讯方舟科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华讯方舟科技有限公司 filed Critical 华讯方舟科技有限公司
Publication of WO2017045491A1 publication Critical patent/WO2017045491A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating

Definitions

  • the present invention belongs to the field of embedded technologies, and in particular, to a method and system for upgrading a sqlite type 3 embedded database.
  • Wireless manager devices for commercial applications have many functions and complicated configurations. Often, a wireless management device needs to configure data of hundreds or even thousands of APs and other items, and requires a large amount of pre-data before use. Configuration work, for this reason, the wireless organizer device in the prior art generally adopts the sqlite3 embedded database. For post-maintenance of wireless manager devices, such as new features and version upgrades, it is often necessary to maintain the database of the wireless manager device, for example: add or delete data tables in the database, one in the data table The field is modified or deleted, and the existing sqlite3 embedded database uses the sqlite3 command.
  • the purpose of the embodiments of the present invention is to provide a method and system for upgrading an sqlite type 3 embedded database, which is to solve the problem that if the wireless manager device needs to upgrade the device version, the entire database must be replaced again. Reconfiguring a large amount of data can make the device upgrade process cumbersome and cumbersome.
  • the embodiment of the present invention is implemented by the method for upgrading an sqlite type 3 embedded database, including:
  • Reading a version number of the target database in the upgrade application software and a version of the source database in the device memory The number determines whether the version number of the target database is consistent with the version number of the source database;
  • the inconsistency is, backing up the source database, and calling an upgrade configuration file embedded in the upgrade application software that matches the version number of the target database and the version number of the source database, according to the The upgrade configuration file upgrades the source database in the device memory.
  • the upgrading of the source database in the device memory according to the upgrade configuration file includes:
  • the upgrade configuration file includes a database structure in the target database and field change information of the data structure in the source database, where the field changes.
  • Information includes: deleting fields, adding fields, modifying field names, modifying field types, and modifying field lengths.
  • the upgrade configuration file is packaged with the upgrade application software in the form of an xml file format, and the upgrade configuration is performed.
  • Each upgrade target in the file is stored as a unit in the form of a linked list so that the upgrade target in the upgrade configuration file is executed in accordance with the linked list order during the database upgrade process.
  • the bit offset of the data stream in the new data table is processed according to the upgrade configuration file to generate
  • the target database specifically includes:
  • the upgrade target is a delete field, searching for the data stream according to the bit to obtain a target bit to be deleted, deleting the information stored at the target bit, and performing data bit shift again;
  • the upgrade target is an add field, searching for the data stream according to the bit to obtain an added position of the field to be added, adding a corresponding field length at the added position, and assigning the newly added field Default data;
  • the upgrade target is a modified field type, calculating a bit offset of the data stream at the position of the field to be modified, deleting the data stream at the position of the field to be modified, and then adding the field, and calculating The bit offset of the data stream at the newly added field position, the difference calculation between the two bit offsets to perform the bit offset, and the default value is written at the position of the newly added field;
  • the upgrade target is to modify the length of the field
  • the bit offset of the data stream is performed according to the length to be changed, and the default value is written.
  • Another object of embodiments of the present invention is to provide a system for upgrading a sqlite type 3 embedded database, including:
  • an application software upgrade module configured to complete loading and restarting the upgrade application software on the device;
  • a determining module configured to read a version number of the target database and the device memory in the upgrade application software a version number of the middle source database, determining whether the version number of the target database is consistent with the version number of the source database;
  • a database upgrade module configured to back up the source database if inconsistent, and invoke a version number embedded in the upgrade application software that matches a version number of the target database and a version number of the source database Upgrading a configuration file, and upgrading the source database in the device memory according to the upgrade configuration file.
  • the database upgrade module includes:
  • a database structure reverse establishing unit configured to acquire a database structure of the target database, and inversely establish a database structure of the source database according to the database structure of the target database and the upgrade configuration file
  • a data stream obtaining unit configured to perform memory space allocation by using a database structure of the source database, to read a data stream of the old data table in the source database;
  • a new data table creating unit configured to delete the old data table, and create a new data table by using a database structure of the target database
  • a data stream bit offset processing unit configured to restore the data stream to the new data table, and according to the The upgrade configuration file processes the bit offset of the data stream in the new data table to generate a target database.
  • the upgrade configuration file includes a database structure in the target database and field change information of the data structure in the source database, and the field change information These include: deleting fields, adding fields, modifying field names, modifying field types, and modifying field lengths.
  • the upgrade configuration file is packaged with the upgrade application software in the form of an xml file format, and the upgrade configuration file is Each upgrade target in the form is stored as a unit in the form of a linked list, so that the upgrade target in the upgrade configuration file is executed according to the linked list order in the database upgrade process.
  • the data stream bit offset processing unit is specifically configured to:
  • the upgrade target is a delete field, searching the data stream according to a bit to obtain a target bit stored in the field to be deleted, deleting information stored at the target bit, and performing data bit shift again;
  • the upgrade target is an add field, searching for the data stream according to the bit to obtain an added position of the field to be added, adding a corresponding field length at the added position, and assigning the newly added field Default data;
  • the upgrade target is a modified field type, calculating a bit offset of the data stream at the position of the field to be modified, deleting the data stream at the position of the field to be modified, and then adding the field, and calculating The bit offset of the data stream at the newly added field position, the difference calculation between the two bit offsets to perform the bit offset, and the default value is written at the position of the newly added field;
  • the upgrade target is to modify the field length
  • the bit offset of the data stream is performed according to the length to be changed, and the default value is written.
  • a method and system for upgrading an sqlite type 3 embedded database provided by an embodiment of the present invention have the following beneficial effects: [0039]
  • the embodiment of the present invention first completes the loading of the upgrade application software on the device and restarts the device; then reads the version number of the target database in the upgrade application software and the version number of the source database in the device memory, and determines Whether the version number of the target database is consistent with the version number of the source database; if not, backing up the source database, and calling the version number and the embedded version of the target database embedded in the upgrade application software An upgrade configuration file matching the version number of the source database, and finally upgrading the source database in the device memory according to the upgrade configuration file, thereby effectively improving the shortage of the existing sqlite3 embedded database, and supplementing
  • the missing feature of the sqlite3 embedded database enables most devices using the sqlite3 embedded database to perform non-destructive upgrade operations, maximally protecting the data in the source database, simplifying the upgrade steps, and shortening the upgrade time. Greatly facilitates the maintenance of equipment and reduces
  • FIG. 1 is a flowchart of a specific implementation of a method for upgrading a sqlite type 3 embedded database according to an embodiment of the present invention
  • FIG. 2 is a flowchart of a specific implementation of upgrading a source database in a device memory according to an upgrade configuration file according to an embodiment of the present invention
  • FIG. 3 is a structural block diagram of a system for upgrading a sqlite type 3 embedded database according to an embodiment of the present invention.
  • FIG. 4 is a structural block diagram of a system for upgrading a sqlite type 3 embedded database according to another embodiment of the present invention.
  • FIG. 1 shows a specific implementation process of a method for upgrading an sqlite3 embedded database provided by an embodiment of the present invention.
  • a method for upgrading an sqlite type 3 embedded database according to an embodiment of the present invention includes: [0046] In S101, loading of the upgrade application software is completed on the device and the device is restarted.
  • a sqlite3 type embedded database is generally used to store configuration and status information.
  • the database used after the application software upgrade may be different from the database used before the upgrade. Therefore, after the upgrade program is loaded, the database in the device memory needs to be upgraded.
  • the device includes, but is not limited to, a wireless manager device, for example: a device or any device using a sqlite type database.
  • the version number of the target database in the upgrade application software and the version number of the source database in the device memory are read, and it is determined whether the version number of the target database is consistent with the version number of the source database. .
  • the upgraded application software automatically has the version number of the target database, and the device automatically reads the upgraded application software during the process of loading the upgrade application software and restarting the device.
  • the target version number and the version number of the source database in the device memory are the same.
  • an application software corresponds to multiple upgrade configuration files
  • the upgrade configuration file is written according to the version number of the target database of the upgraded application software, for example: if the target of the upgraded application software
  • the database version number is version 3
  • the upgrade configuration files packaged with the application software include: an upgrade configuration file upgraded from version 1 to version 3 and an upgrade configuration file upgraded from version 2 to version 3.
  • the upgrade configuration file includes a database structure in the target database and field change information of the data structure in the source database, where the field change information includes: deleting a field, adding a field, modifying a field name, modifying a field type, and modifying a field length.
  • upgrade configuration file is embedded in the upgrade application software in the form of an xml file format, and each upgrade target in the upgrade configuration file is stored as a unit in a linked list, so as to be The linked list sequentially performs an upgrade target in the upgrade configuration file.
  • FIG. 2 shows a specific implementation process of upgrading the source database in the device memory according to the upgrade configuration file in step S103.
  • the process includes: [0053] In S201, a database structure of the target database is obtained, and a database structure of the source database is reversely established according to a database structure of the target database and the upgrade configuration file.
  • the corresponding old database structure since the table data in the source database is extracted, the corresponding old database structure must be used for memory space allocation and data extraction, and the database structure in the upgraded application software is the target database.
  • the new database structure so after the upgrade, the old database structure of the source database needs to be reversed according to the new database structure and the corresponding upgrade configuration file, wherein the upgrade configuration file records the difference information between the new database structure and the old database structure.
  • a memory space allocation is performed by using a database structure of the source database to read a data stream of the old data table in the source database.
  • the malloc () function is used for memory space allocation.
  • the data stream is restored to the new data table, and a bit offset of the data stream in the new data table is processed according to the upgrade configuration file to generate a target database.
  • To generate the target database specifically includes:
  • the upgrade target is a delete field
  • the data stream is searched according to a bit to obtain a target bit to be deleted, the information stored at the target bit is deleted, and the data bit offset is performed again.
  • each target bit information that is found needs to be processed, and all the information stored in the corresponding field position is deleted, and the information is re-executed. Data bit offset.
  • the upgrade target is an add field
  • searching for the data stream according to the bit to obtain an added position of the field to be added adding a corresponding field length at the added position, and assigning the newly added field The default data.
  • a plurality of added locations are found, it is necessary to process each of the plurality of added locations found.
  • the upgrade target is a modified field type, calculating a bit offset of the data stream at the position of the field to be modified, deleting the data stream at the position of the field to be modified, and then adding the field, and calculating New Add the bit offset of the data stream at the field location, perform a difference calculation on the two bit offsets, perform a bit offset, and write a default value at the location of the newly added field.
  • the upgrade target is to change the field type from int to char, delete the length of 4 bytes occupied by the original int field, and then add the default value corresponding to the char type field to perform data stream bit shift. shift.
  • the upgrade target is to modify the length of the field
  • the bit offset of the data stream is performed according to the length to be changed, and the default value is written.
  • the modified field length refers specifically to a char string.
  • the upgrade target is to change the length of the char type field from temp[20] to temp[10]
  • the extracted data in the old data has more than 10 bytes of content
  • delete the data add the default value of 10 bytes, if the old data is less than or equal to 10 bytes, it will not be modified.
  • the upgrade target is to change the char field length from Temp[10] to temp[20]
  • no modification is required.
  • the backup source database may be reversely upgraded to the old version in the event of an error in the database upgrade process. Database.
  • the embodiment of the present invention provides a method for upgrading an sqlite type 3 embedded database, which can implement an upgrade of the database by extracting and splitting existing data in the database. Effectively improve the existing sqlite3 embedded database, supplement the missing function of sqlite3 embedded database, can make most of the devices using sqlite3 embedded database can perform non-destructive upgrade operation, maximally protect the source database.
  • the data in the simplifies the upgrade steps, shortens the upgrade time, and greatly facilitates the maintenance of the equipment, reducing the workload of maintenance personnel.
  • FIG. 3 is a structural block diagram of a system for upgrading an sqlite3 type embedded database according to an embodiment of the present invention.
  • the system is located in the device according to the embodiment of the present invention, and is used to run the above FIG. 1 to FIG. 2 The method provided by the illustrated embodiment. Only the parts related to the present embodiment are shown for convenience of explanation.
  • an embodiment of the present invention provides a system for upgrading a sqlite3 embedded database, including:
  • the application software upgrade module 1 is configured to complete loading and restarting the upgrade application software on the device.
  • the determining module 2 is configured to read the version number of the target database in the upgrade application software and the device. Inside a version number of the source database, determining whether the version number of the target database is consistent with the version number of the source database;
  • the database upgrade module 3 is configured to perform backup on the source database if inconsistency, and invoke a version number embedded in the upgrade application software to match the version number of the target database and the version number of the source database.
  • the upgrade configuration file, the source database in the device memory is upgraded according to the upgrade configuration file.
  • the database upgrade module 3 includes:
  • a database structure reverse establishing unit 31 configured to acquire a database structure of the target database, and inversely establish a database structure of the source database according to the database structure of the target database and the upgrade configuration file;
  • a data stream obtaining unit 32 configured to perform memory space allocation by using a database structure of the source database, to read a data stream of the old data table in the source database;
  • a new data table creating unit 33 configured to delete the old data table, and create a new data table by using a database structure of the target database
  • a data stream bit offset processing unit 34 configured to restore the data stream to the new data table, and process a bit offset of the data stream in the new data table according to the upgrade configuration file. To generate the target database.
  • the upgrade configuration file includes a database structure in the target database and field change information of the data structure in the source database, where the field change information includes: deleting a field, adding a field, modifying a field name, modifying a field type, and Modify the field length.
  • the upgrade configuration file is embedded in the upgrade application software in an xml file format, and each upgrade target in the upgrade configuration file is stored as a unit in a linked list, so that Performing the upgrade target in the upgrade configuration file according to the linked list sequence during the database upgrade process
  • the data stream bit offset processing unit 34 is specifically configured to:
  • the upgrade target is a delete field, searching the data stream according to a bit to obtain a target bit stored in the field to be deleted, deleting information stored at the target bit, and performing data bit shift again;
  • the upgrade target is an add field, searching for the data stream according to a bit to obtain a word to be added Adding a position of the segment, adding a corresponding field length at the added position, and assigning default data to the newly added field;
  • the upgrade target is a modified field type, calculating a bit offset of the data stream at the position of the field to be modified, deleting the data stream at the position of the field to be modified, and then adding the field, and calculating The bit offset of the data stream at the newly added field position, the difference calculation between the two bit offsets to perform the bit offset, and the default value is written at the position of the newly added field;
  • the upgrade target is to modify the length of the field
  • the bit offset of the data stream is performed according to the length to be changed, and the default value is written.
  • the system for upgrading the sqlite3 embedded database provided by the embodiment of the present invention can also implement the database upgrade by using the extraction and splitting of the existing data in the database.
  • Improve the existing sqlite3 embedded database, supplement the missing function of sqlite3 embedded database can make most of the devices using sqlite3 embedded database can perform non-destructive upgrade operation, maximally protect the source database
  • FIG. 4 is a structural block diagram of a system for upgrading a sqlite3 type embedded database according to another embodiment of the present invention.
  • the system is located in the device according to the embodiment of the present invention, and is used to run the method provided in the embodiment shown in FIG. 1 to FIG. 2 above. Only the parts related to the present embodiment are shown for convenience of explanation.
  • the embodiment provides a system for upgrading a sqlite3 embedded database, including
  • processor 410 communication interface 420, memory
  • bus 440 (memory) 430, bus 440.
  • the processor 410, the communication interface 420, and the memory 430 complete communication with each other through the bus 440.
  • the communication interface 420 is configured to communicate with an external device, such as a personal computer, a server, or the like.
  • the processor 410 is configured to execute the program 431.
  • the program 431 may include program code, the program code including computer operation instructions.
  • the processor 410 may be a central processing unit CPU, or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention.
  • CPU central processing unit
  • ASIC application specific integrated circuit
  • the memory 430 is configured to store the program 431.
  • the memory 430 may include a high speed RAM memory and may also include a non-volatile memory such as at least one disk memory.
  • the program 431 may specifically include:
  • application software upgrade module 1 used to complete the loading of the upgrade application software on the device and restart the device
  • the determining module 2 is configured to read a version number of the target database in the upgrade application software and a version number of the source database in the device memory, and determine a version number of the target database and a version number of the source database. Consistent;
  • the database upgrade module 3 is configured to perform backup on the source database if inconsistency, and invoke the version number of the target database embedded in the upgrade application software to match the version number of the source database.
  • the upgrade configuration file, the source database in the device memory is upgraded according to the upgrade configuration file.
  • the disclosed system, apparatus, and method may be implemented in other manners.
  • the device embodiments described above are merely illustrative.
  • the division of the unit is only a logical function division, and the actual implementation may have another division manner, for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not executed.
  • the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some communication interface, device or unit, and may be in electrical, mechanical or other form.
  • the unit described as a separate component may or may not be physically distributed.
  • the component displayed as a unit may or may not be a physical unit, that is, may be located in one place, or may be located in one place. Distributed to multiple network elements. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the functions, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium.
  • the technical solution of the present invention which is essential or contributes to the prior art, or a part of the technical solution, may be embodied in the form of a software product, which is stored in a storage medium, including
  • the instructions are used to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention.
  • the foregoing storage medium includes: u disk
  • RAM random access memory
  • disk disk or optical disk, and other media that can store program code.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Stored Programmes (AREA)

Abstract

A method and a system for upgrading an sqlite3 embedded database, relating to the embedded technical field. Said method comprises: loading upgrade application software on a device and re-starting the device; reading the version number of the target database in the upgrade application software and the version number of the source database in a device memory, and determining whether the version number of the target database is consistent with the version number of the source database; if the version numbers are inconsistent with each other, backing up the source database and invoking an upgrade configuration file embedded in the upgrade application software, which matches the version number of the target database and the version number of the source database, and upgrading, according to the upgrade configuration file, the source database in the device memory. This enables most devices using an sqlite3 embedded database to perform non-destructive upgrade operation, protecting, to the greatest extent, data in the source database, simplifying the upgrade steps, shortening the upgrade time, and greatly facilitating the maintenance of the device and reducing the workload of the maintenance staff.

Description

说明书 发明名称:一种对 sqlite3型嵌入式数据库进行升级的方法及系统 技术领域  Description: A method and system for upgrading a sqlite3 embedded database
[0001] 本发明属于嵌入式技术领域, 尤其涉及一种对 sqlite3型嵌入式数据库进行升级 的方法及系统。  [0001] The present invention belongs to the field of embedded technologies, and in particular, to a method and system for upgrading a sqlite type 3 embedded database.
背景技术  Background technique
[0002] 商业场合应用的无线管理器设备由于功能较多、 配置复杂, 经常一台无线管理 设备需要配置几百甚至上千个 AP的数据以及其他条目, 而且在使用前需要进行 大量的前期数据配置工作, 为此现有技术中的无线管理器设备一般采用 sqlite3嵌 入式数据库。 而对无线管理器设备进行后期维护, 如新功能增加以及版本升级 的吋候, 经常需要对无线管理器设备的数据库进行维护, 例如: 添加或刪除数 据库中的数据表、 对数据表里某个字段进行修改或刪除等, 而现有的 sqlite3嵌入 式数据库在使用 sqlite3命令的吋候, 因为 sqlite3本身的功能缺失, 无法通过命令 来对数据库表字段进行刪除和修改, 这样无线管理器设备若需要升级设备版本 , 则必须重新更换整个数据库导致设备必须得重新配置大量数据, 这样会使设 备升级过程繁琐、 耗吋。  [0002] Wireless manager devices for commercial applications have many functions and complicated configurations. Often, a wireless management device needs to configure data of hundreds or even thousands of APs and other items, and requires a large amount of pre-data before use. Configuration work, for this reason, the wireless organizer device in the prior art generally adopts the sqlite3 embedded database. For post-maintenance of wireless manager devices, such as new features and version upgrades, it is often necessary to maintain the database of the wireless manager device, for example: add or delete data tables in the database, one in the data table The field is modified or deleted, and the existing sqlite3 embedded database uses the sqlite3 command. Because the function of sqlite3 itself is missing, the database table field cannot be deleted and modified by the command, so that the wireless manager device needs To upgrade the device version, you must re-replace the entire database, causing the device to have to reconfigure a large amount of data, which makes the device upgrade process cumbersome and cumbersome.
技术问题  technical problem
[0003] 本发明实施例的目的在于提供一种对 sqlite3型嵌入式数据库进行升级的方法及 系统, 旨在解决上述无线管理器设备若需要升级设备版本, 则必须重新更换整 个数据库导致设备必须得重新配置大量数据, 这样会使设备升级过程繁琐、 耗 吋的问题。  [0003] The purpose of the embodiments of the present invention is to provide a method and system for upgrading an sqlite type 3 embedded database, which is to solve the problem that if the wireless manager device needs to upgrade the device version, the entire database must be replaced again. Reconfiguring a large amount of data can make the device upgrade process cumbersome and cumbersome.
问题的解决方案  Problem solution
技术解决方案  Technical solution
[0004] 本发明实施例是这样实现的, 一种对 sqlite3型嵌入式数据库进行升级的方法, 包括:  [0004] The embodiment of the present invention is implemented by the method for upgrading an sqlite type 3 embedded database, including:
[0005] 在设备上完成升级应用软件的加载并重新启动设备;  [0005] completing the loading of the upgrade application software on the device and restarting the device;
[0006] 读取所述升级应用软件中目标数据库的版本号和所述设备内存中源数据库的版 本号, 判断所述目标数据库的版本号与所述源数据库的版本号是否一致; Reading a version number of the target database in the upgrade application software and a version of the source database in the device memory The number determines whether the version number of the target database is consistent with the version number of the source database;
[0007] 若不一致, 则对所述源数据库进行备份, 并调用所述升级应用软件内嵌的与所 述目标数据库的版本号和所述源数据库的版本号相匹配的升级配置文件, 根据 所述升级配置文件对所述设备内存中的所述源数据库进行升级。  [0007] if the inconsistency is, backing up the source database, and calling an upgrade configuration file embedded in the upgrade application software that matches the version number of the target database and the version number of the source database, according to the The upgrade configuration file upgrades the source database in the device memory.
[0008] 在本发明是实施例所述的对 sqlite3型嵌入式数据库进行升级的方法中, 根据所 述升级配置文件对所述设备内存中的源数据库进行升级具体包括:  [0008] In the method for upgrading the sqlite type 3 embedded database according to the embodiment of the present invention, the upgrading of the source database in the device memory according to the upgrade configuration file includes:
[0009] 获取目标数据库的数据库结构, 根据所述目标数据库的数据库结构和所述升级 配置文件逆向建立所述源数据库的数据库结构;  Obtaining a database structure of the target database, and establishing a database structure of the source database in reverse according to the database structure of the target database and the upgrade configuration file;
[0010] 利用所述源数据库的数据库结构进行内存空间分配, 以读取所述源数据库中旧 数据表的数据流;  [0010] performing a memory space allocation by using a database structure of the source database to read a data stream of the old data table in the source database;
[0011] 刪除所述旧数据表, 并利用所述目标数据库的数据库结构创建新数据表; [0012] 将所述数据流恢复到所述新数据表中, 并根据所述升级配置文件对所述新数据 表中数据流的位偏移进行处理, 以生成目标数据库。  [0011] deleting the old data table, and creating a new data table by using a database structure of the target database; [0012] restoring the data stream to the new data table, and according to the upgrade configuration file The bit offset of the data stream in the new data table is processed to generate a target database.
[0013] 在本发明是实施例所述的对 sqlite3型嵌入式数据库进行升级的方法中, 所述升 级配置文件包括目标数据库中数据库结构以及源数据库中数据结构的字段变化 信息, 所述字段变化信息包括: 刪除字段、 添加字段、 修改字段名称、 修改字 段类型以及修改字段长度。  [0013] In the method for upgrading the sqlite3 type embedded database according to the embodiment of the present invention, the upgrade configuration file includes a database structure in the target database and field change information of the data structure in the source database, where the field changes. Information includes: deleting fields, adding fields, modifying field names, modifying field types, and modifying field lengths.
[0014] 在本发明是实施例所述的对 sqlite3型嵌入式数据库进行升级的方法中, 所述升 级配置文件以 xml文件格式的形式与所述升级应用软件打包在一起, 且所述升级 配置文件中的每个升级目标作为一个单元以链表的形式存储, 以便在数据库升 级过程中根据所述链表顺序执行所述升级配置文件中的升级目标。  [0014] In the method for upgrading the sqlite3 type embedded database according to the embodiment of the present invention, the upgrade configuration file is packaged with the upgrade application software in the form of an xml file format, and the upgrade configuration is performed. Each upgrade target in the file is stored as a unit in the form of a linked list so that the upgrade target in the upgrade configuration file is executed in accordance with the linked list order during the database upgrade process.
[0015] 在本发明是实施例所述的对 sqlite3型嵌入式数据库进行升级的方法中, 所述根 据所述升级配置文件对所述新数据表中数据流的位偏移进行处理, 以生成目标 数据库具体包括:  [0015] In the method for upgrading the sqlite3 type embedded database according to the embodiment of the present invention, the bit offset of the data stream in the new data table is processed according to the upgrade configuration file to generate The target database specifically includes:
[0016] 若所述升级目标为刪除字段, 则对所述数据流按照位进行査找以获取待刪除字 段存储的目标位, 刪除所述目标位处存储的信息, 并重新进行数据位偏移; [0016] if the upgrade target is a delete field, searching for the data stream according to the bit to obtain a target bit to be deleted, deleting the information stored at the target bit, and performing data bit shift again;
[0017] 若所述升级目标为添加字段, 则对所述数据流按照位进行査找以获取待添加字 段的添加位置, 在所述添加位置处添加对应的字段长度, 并给新添加的字段赋 默认的数据; [0017] if the upgrade target is an add field, searching for the data stream according to the bit to obtain an added position of the field to be added, adding a corresponding field length at the added position, and assigning the newly added field Default data;
[0018] 若所述升级目标为修改字段名称, 则不进行处理;  [0018] if the upgrade target is to modify the field name, no processing is performed;
[0019] 若所述升级目标为修改字段类型, 则计算出待修改字段位置处数据流的位偏移 量, 并刪除所述待修改字段位置处的数据流, 然后进行字段添加, 并计算出新 添加字段位置处数据流的位偏移量, 对两个位偏移量进行差值计算, 以进行位 偏移, 并在新添加字段的位置处写入默认值;  [0019] if the upgrade target is a modified field type, calculating a bit offset of the data stream at the position of the field to be modified, deleting the data stream at the position of the field to be modified, and then adding the field, and calculating The bit offset of the data stream at the newly added field position, the difference calculation between the two bit offsets to perform the bit offset, and the default value is written at the position of the newly added field;
[0020] 若所述升级目标为修改字段长度, 则根据待改动长度进行数据流的位偏移, 并 写入默认值。  [0020] If the upgrade target is to modify the length of the field, the bit offset of the data stream is performed according to the length to be changed, and the default value is written.
[0021] 本发明实施例的另一目的在于提供一种对 sqlite3型嵌入式数据库进行升级的系 统, 包括:  [0021] Another object of embodiments of the present invention is to provide a system for upgrading a sqlite type 3 embedded database, including:
[0022] 应用软件升级模块, 用于在设备上完成升级应用软件的加载并重新启动设备; [0023] 判断模块, 用于读取所述升级应用软件中目标数据库的版本号和所述设备内存 中源数据库的版本号, 判断所述目标数据库的版本号与所述源数据库的版本号 是否一致;  [0022] an application software upgrade module, configured to complete loading and restarting the upgrade application software on the device; [0023] a determining module, configured to read a version number of the target database and the device memory in the upgrade application software a version number of the middle source database, determining whether the version number of the target database is consistent with the version number of the source database;
[0024] 数据库升级模块, 用于若不一致, 则对所述源数据库进行备份, 并调用所述升 级应用软件内嵌的与所述目标数据库的版本号和所述源数据库的版本号相匹配 的升级配置文件, 根据所述升级配置文件对所述设备内存中的所述源数据库进 行升级。  [0024] a database upgrade module, configured to back up the source database if inconsistent, and invoke a version number embedded in the upgrade application software that matches a version number of the target database and a version number of the source database Upgrading a configuration file, and upgrading the source database in the device memory according to the upgrade configuration file.
[0025] 在本发明实施例所述的对 sqlite3型嵌入式数据库进行升级的系统中, 所述数据 库升级模块包括:  [0025] In the system for upgrading the sqlite type 3 embedded database according to the embodiment of the present invention, the database upgrade module includes:
[0026] 数据库结构逆向建立单元, 用于获取目标数据库的数据库结构, 根据所述目标 数据库的数据库结构和所述升级配置文件逆向建立所述源数据库的数据库结构  [0026] a database structure reverse establishing unit, configured to acquire a database structure of the target database, and inversely establish a database structure of the source database according to the database structure of the target database and the upgrade configuration file
[0027] 数据流获取单元, 用于利用所述源数据库的数据库结构进行内存空间分配, 以 读取所述源数据库中旧数据表的数据流; [0027] a data stream obtaining unit, configured to perform memory space allocation by using a database structure of the source database, to read a data stream of the old data table in the source database;
[0028] 新数据表创建单元, 用于刪除所述旧数据表, 并利用所述目标数据库的数据库 结构创建新数据表; [0028] a new data table creating unit, configured to delete the old data table, and create a new data table by using a database structure of the target database;
[0029] 数据流位偏移处理单元, 用于将所述数据流恢复到所述新数据表中, 并根据所 述升级配置文件对所述新数据表中数据流的位偏移进行处理, 以生成目标数据 库。 [0029] a data stream bit offset processing unit, configured to restore the data stream to the new data table, and according to the The upgrade configuration file processes the bit offset of the data stream in the new data table to generate a target database.
[0030] 在本发明实施例所述的对 sqlite3型嵌入式数据库进行升级的系统中, 所述升级 配置文件包括目标数据库中数据库结构以及源数据库中数据结构的字段变化信 息, 所述字段变化信息包括: 刪除字段、 添加字段、 修改字段名称、 修改字段 类型以及修改字段长度。  [0030] In the system for upgrading the sqlite3 type embedded database according to the embodiment of the present invention, the upgrade configuration file includes a database structure in the target database and field change information of the data structure in the source database, and the field change information These include: deleting fields, adding fields, modifying field names, modifying field types, and modifying field lengths.
[0031] 在本发明实施例所述的对 sqlite3型嵌入式数据库进行升级的系统中, 所述升级 配置文件以 xml文件格式的形式与所述升级应用软件打包在一起, 且所述升级配 置文件中的每个升级目标作为一个单元以链表的形式存储, 以便在数据库升级 过程中根据所述链表顺序执行所述升级配置文件中的升级目标。  [0031] In the system for upgrading the sqlite3 type embedded database according to the embodiment of the present invention, the upgrade configuration file is packaged with the upgrade application software in the form of an xml file format, and the upgrade configuration file is Each upgrade target in the form is stored as a unit in the form of a linked list, so that the upgrade target in the upgrade configuration file is executed according to the linked list order in the database upgrade process.
[0032] 在本发明实施例所述的对 sqlite3型嵌入式数据库进行升级的系统中, 所述数据 流位偏移处理单元具体用于:  [0032] In the system for upgrading the sqlite type 3 embedded database in the embodiment of the present invention, the data stream bit offset processing unit is specifically configured to:
[0033] 若所述升级目标为刪除字段, 则对所述数据流按照位进行査找以获取待刪除字 段存储的目标位, 刪除所述目标位处存储的信息, 并重新进行数据位偏移;  [0033] if the upgrade target is a delete field, searching the data stream according to a bit to obtain a target bit stored in the field to be deleted, deleting information stored at the target bit, and performing data bit shift again;
[0034] 若所述升级目标为添加字段, 则对所述数据流按照位进行査找以获取待添加字 段的添加位置, 在所述添加位置处添加对应的字段长度, 并给新添加的字段赋 默认的数据;  [0034] if the upgrade target is an add field, searching for the data stream according to the bit to obtain an added position of the field to be added, adding a corresponding field length at the added position, and assigning the newly added field Default data;
[0035] 若所述升级目标为修改字段名称, 则不进行处理;  [0035] if the upgrade target is to modify the field name, no processing is performed;
[0036] 若所述升级目标为修改字段类型, 则计算出待修改字段位置处数据流的位偏移 量, 并刪除所述待修改字段位置处的数据流, 然后进行字段添加, 并计算出新 添加字段位置处数据流的位偏移量, 对两个位偏移量进行差值计算, 以进行位 偏移, 并在新添加字段的位置处写入默认值;  [0036] if the upgrade target is a modified field type, calculating a bit offset of the data stream at the position of the field to be modified, deleting the data stream at the position of the field to be modified, and then adding the field, and calculating The bit offset of the data stream at the newly added field position, the difference calculation between the two bit offsets to perform the bit offset, and the default value is written at the position of the newly added field;
[0037] 若所述升级目标为修改字段长度, 则根据待改动长度进行数据流的位偏移, 并 写入默认值。  [0037] If the upgrade target is to modify the field length, the bit offset of the data stream is performed according to the length to be changed, and the default value is written.
发明的有益效果  Advantageous effects of the invention
有益效果  Beneficial effect
[0038] 实施本发明实施例提供的一种对 sqlite3型嵌入式数据库进行升级的方法及系统 具有以下有益效果: [0039] 本发明实施例由于首先在设备上完成升级应用软件的加载并重新启动设备; 然 后读取所述升级应用软件中目标数据库的版本号和所述设备内存中源数据库的 版本号, 判断所述目标数据库的版本号与所述源数据库的版本号是否一致; 若 不一致, 则对所述源数据库进行备份, 并调用所述升级应用软件内嵌的与所述 目标数据库的版本号和所述源数据库的版本号相匹配的升级配置文件, 最后根 据所述升级配置文件对所述设备内存中的所述源数据库进行升级, 从而有效的 完善了现有 sqlite3嵌入式数据库的不足, 补充了 sqlite3嵌入式数据库缺失的功能 , 能够使大部分使用 sqlite3型嵌入式数据库的设备均可以进行无损升级操作, 最 大程度的保护了源数据库中的数据, 简化了升级步骤、 缩短了升级吋间, 并且 极大地方便了设备的维护, 减少了维护人员的工作量。 [0038] A method and system for upgrading an sqlite type 3 embedded database provided by an embodiment of the present invention have the following beneficial effects: [0039] The embodiment of the present invention first completes the loading of the upgrade application software on the device and restarts the device; then reads the version number of the target database in the upgrade application software and the version number of the source database in the device memory, and determines Whether the version number of the target database is consistent with the version number of the source database; if not, backing up the source database, and calling the version number and the embedded version of the target database embedded in the upgrade application software An upgrade configuration file matching the version number of the source database, and finally upgrading the source database in the device memory according to the upgrade configuration file, thereby effectively improving the shortage of the existing sqlite3 embedded database, and supplementing The missing feature of the sqlite3 embedded database enables most devices using the sqlite3 embedded database to perform non-destructive upgrade operations, maximally protecting the data in the source database, simplifying the upgrade steps, and shortening the upgrade time. Greatly facilitates the maintenance of equipment and reduces maintenance personnel For the amount.
对附图的简要说明  Brief description of the drawing
附图说明  DRAWINGS
[0040] 图 1是本发明实施例提供的对 sqlite3型嵌入式数据库进行升级的方法的具体实现 流程图;  1 is a flowchart of a specific implementation of a method for upgrading a sqlite type 3 embedded database according to an embodiment of the present invention;
[0041] 图 2是本发明实施例中根据升级配置文件对设备内存中的源数据库进行升级的 具体实现流程图;  [0041] FIG. 2 is a flowchart of a specific implementation of upgrading a source database in a device memory according to an upgrade configuration file according to an embodiment of the present invention;
[0042] 图 3是本发明实施例提供的对 sqlite3型嵌入式数据库进行升级的系统的结构框图  3 is a structural block diagram of a system for upgrading a sqlite type 3 embedded database according to an embodiment of the present invention.
[0043] 图 4是本发明另一实施例提供的对 sqlite3型嵌入式数据库进行升级的系统的结构 框图。 4 is a structural block diagram of a system for upgrading a sqlite type 3 embedded database according to another embodiment of the present invention.
本发明的实施方式 Embodiments of the invention
[0044] 为了使本发明的目的、 技术方案及优点更加清楚明白, 以下结合附图及实施例 [0044] In order to make the objects, technical solutions and advantages of the present invention more clear, the following is in conjunction with the accompanying drawings and embodiments.
, 对本发明进行进一步详细说明。 应当理解, 此处所描述的具体实施例仅仅用 以解释本发明, 并不用于限定本发明。 The present invention will be further described in detail. It is understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0045] 图 1示出了本发明实施例提供的对 sqlite3型嵌入式数据库进行升级的方法的具体 实现流程。 参见图 1所示, 本发明实施例提供的一种对 sqlite3型嵌入式数据库进 行升级的方法, 包括: [0046] 在 S101中, 在设备上完成升级应用软件的加载并重新启动设备。 [0045] FIG. 1 shows a specific implementation process of a method for upgrading an sqlite3 embedded database provided by an embodiment of the present invention. Referring to FIG. 1 , a method for upgrading an sqlite type 3 embedded database according to an embodiment of the present invention includes: [0046] In S101, loading of the upgrade application software is completed on the device and the device is restarted.
[0047] 在本发明实施例中, 对于基于嵌入式应用软件的设备而言, 一般采用 sqlite3型 嵌入式数据库来存储配置和状态信息。 在对设备上的应用软件进行升级吋, 由 于应用软件升级后使用的数据库可能与升级前使用的数据库不同, 因此在加载 完升级程序后还需要对设备内存中的数据库进行升级处理。 进一步的, 所述设 备包括但不限于无线管理器设备, 例如: 还可以路由设备或者任何使用 sqlite型 数据库的设备。 [0047] In the embodiment of the present invention, for an embedded application software-based device, a sqlite3 type embedded database is generally used to store configuration and status information. After upgrading the application software on the device, the database used after the application software upgrade may be different from the database used before the upgrade. Therefore, after the upgrade program is loaded, the database in the device memory needs to be upgraded. Further, the device includes, but is not limited to, a wireless manager device, for example: a device or any device using a sqlite type database.
[0048] 在 S102中, 读取所述升级应用软件中目标数据库的版本号和所述设备内存中源 数据库的版本号, 判断所述目标数据库的版本号与所述源数据库的版本号是否 一致。  [0048] In S102, the version number of the target database in the upgrade application software and the version number of the source database in the device memory are read, and it is determined whether the version number of the target database is consistent with the version number of the source database. .
[0049] 在本发明实施例中, 升级后的应用软件自带有目标数据库的版本号, 设备在完 成升级应用软件的加载并重新启动设备的过程中会自动读取升级后的应用软件 自带的目标版本号和设备内存中源数据库的版本号。  [0049] In the embodiment of the present invention, the upgraded application software automatically has the version number of the target database, and the device automatically reads the upgraded application software during the process of loading the upgrade application software and restarting the device. The target version number and the version number of the source database in the device memory.
[0050] 在 S103中, 若不一致, 则对所述源数据库进行备份, 并调用所述升级应用软件 内嵌的与所述目标数据库的版本号和所述源数据库的版本号相匹配的升级配置 文件, 根据所述升级配置文件对所述设备内存中的所述源数据库进行升级。  [0050] In S103, if not, the source database is backed up, and the upgrade configuration embedded in the upgrade application software that matches the version number of the target database and the version number of the source database is invoked. File, upgrading the source database in the device memory according to the upgrade configuration file.
[0051] 在本发明实施例中, 一个应用软件对应有多个升级配置文件, 升级配置文件是 根据升级后的应用软件的目标数据库的版本号编写的, 例如: 若升级后的应用 软件的目标数据库版本号为第 3版, 则与所述应用软件一起打包的升级配置文件 包括: 从版本 1升级到版本 3的升级配置文件和从版本 2升级到版本 3的升级配置 文件。 具体的, 所述升级配置文件包括目标数据库中数据库结构以及源数据库 中数据结构的字段变化信息, 所述字段变化信息包括: 刪除字段、 添加字段、 修改字段名称、 修改字段类型以及修改字段长度。 且所述升级配置文件以 xml文 件格式的形式内嵌于所述升级应用软件中, 且所述升级配置文件中的每个升级 目标作为一个单元以链表的形式存储, 以便在数据库升级过程中根据所述链表 顺序执行所述升级配置文件中的升级目标。  [0051] In the embodiment of the present invention, an application software corresponds to multiple upgrade configuration files, and the upgrade configuration file is written according to the version number of the target database of the upgraded application software, for example: if the target of the upgraded application software The database version number is version 3, and the upgrade configuration files packaged with the application software include: an upgrade configuration file upgraded from version 1 to version 3 and an upgrade configuration file upgraded from version 2 to version 3. Specifically, the upgrade configuration file includes a database structure in the target database and field change information of the data structure in the source database, where the field change information includes: deleting a field, adding a field, modifying a field name, modifying a field type, and modifying a field length. And the upgrade configuration file is embedded in the upgrade application software in the form of an xml file format, and each upgrade target in the upgrade configuration file is stored as a unit in a linked list, so as to be The linked list sequentially performs an upgrade target in the upgrade configuration file.
[0052] 作为一具体实现示例, 图 2示出了步骤 S103中根据所述升级配置文件对所述设 备内存中的源数据库进行升级的具体实现过程, 参见图 2所示, 该过程包括: [0053] 在 S201中, 获取目标数据库的数据库结构, 根据所述目标数据库的数据库结构 和所述升级配置文件逆向建立所述源数据库的数据库结构。 [0052] As a specific implementation example, FIG. 2 shows a specific implementation process of upgrading the source database in the device memory according to the upgrade configuration file in step S103. Referring to FIG. 2, the process includes: [0053] In S201, a database structure of the target database is obtained, and a database structure of the source database is reversely established according to a database structure of the target database and the upgrade configuration file.
[0054] 在本发明实施例中, 由于提取源数据库中的表数据吋, 必须使用对应的旧数据 库结构进行内存空间分配和数据提取, 而此吋升级后的应用软件中的数据库结 构为目标数据库的新数据库结构, 所以在升级吋, 需要根据新数据库结构体和 对应的升级配置文件逆向建立源数据库的旧数据库结构, 其中升级配置文件中 记录有新数据库结构和旧数据库结构的差异信息。  [0054] In the embodiment of the present invention, since the table data in the source database is extracted, the corresponding old database structure must be used for memory space allocation and data extraction, and the database structure in the upgraded application software is the target database. The new database structure, so after the upgrade, the old database structure of the source database needs to be reversed according to the new database structure and the corresponding upgrade configuration file, wherein the upgrade configuration file records the difference information between the new database structure and the old database structure.
[0055] 在 S202中, 利用所述源数据库的数据库结构进行内存空间分配, 以读取所述源 数据库中旧数据表的数据流。 在本发明实施例中, 采用 malloc () 函数进行内存 空间分配。  [0055] In S202, a memory space allocation is performed by using a database structure of the source database to read a data stream of the old data table in the source database. In the embodiment of the present invention, the malloc () function is used for memory space allocation.
[0056] 在 S203中, 刪除所述旧数据表, 并利用所述目标数据库的数据库结构创建新数 据表。  [0056] In S203, the old data table is deleted, and a new data table is created by using the database structure of the target database.
[0057] 在 S204中, 将所述数据流恢复到所述新数据表中, 并根据所述升级配置文件对 所述新数据表中数据流的位偏移进行处理, 以生成目标数据库。  [0057] In S204, the data stream is restored to the new data table, and a bit offset of the data stream in the new data table is processed according to the upgrade configuration file to generate a target database.
[0058] 其中, 所述根据所述升级配置文件对所述新数据表中数据流的位偏移进行处理[0058] wherein, the processing, according to the upgrade configuration file, processing a bit offset of a data stream in the new data table
, 以生成目标数据库具体包括: To generate the target database specifically includes:
[0059] 若所述升级目标为刪除字段, 则对所述数据流按照位进行査找以获取待刪除字 段存储的目标位, 刪除所述目标位处存储的信息, 并重新进行数据位偏移。 [0059] If the upgrade target is a delete field, the data stream is searched according to a bit to obtain a target bit to be deleted, the information stored at the target bit is deleted, and the data bit offset is performed again.
[0060] 在本发明实施例中, 若査找出来的不止一条目标位信息, 则需要对査找到的每 条目标位信息都进行处理, 刪除査找到的所有对应字段位置存储的信息, 并且 重新进行数据位偏移。 [0060] In the embodiment of the present invention, if more than one target bit information is found, each target bit information that is found needs to be processed, and all the information stored in the corresponding field position is deleted, and the information is re-executed. Data bit offset.
[0061] 若所述升级目标为添加字段, 则对所述数据流按照位进行査找以获取待添加字 段的添加位置, 在所述添加位置处添加对应的字段长度, 并给新添加的字段赋 默认的数据。 同样, 在本发明实施例中, 若査找出多个添加位置, 则需要对査 找到的多个添加位置中的每一个添加位置都进行处理。  [0061] if the upgrade target is an add field, searching for the data stream according to the bit to obtain an added position of the field to be added, adding a corresponding field length at the added position, and assigning the newly added field The default data. Similarly, in the embodiment of the present invention, if a plurality of added locations are found, it is necessary to process each of the plurality of added locations found.
[0062] 若所述升级目标为修改字段名称, 则不进行处理。  [0062] If the upgrade target is to modify the field name, no processing is performed.
[0063] 若所述升级目标为修改字段类型, 则计算出待修改字段位置处数据流的位偏移 量, 并刪除所述待修改字段位置处的数据流, 然后进行字段添加, 并计算出新 添加字段位置处数据流的位偏移量, 对两个位偏移量进行差值计算, 以进行位 偏移, 并在新添加字段的位置处写入默认值。 作为一具体实现示例: 若所述升 级目标为将字段类型由 int改为 char, 则刪除原来 int型字段所占的 4字节长度, 然 后添加 char型字段对应的默认值, 进行数据流位偏移。 [0063] if the upgrade target is a modified field type, calculating a bit offset of the data stream at the position of the field to be modified, deleting the data stream at the position of the field to be modified, and then adding the field, and calculating New Add the bit offset of the data stream at the field location, perform a difference calculation on the two bit offsets, perform a bit offset, and write a default value at the location of the newly added field. As a specific implementation example: If the upgrade target is to change the field type from int to char, delete the length of 4 bytes occupied by the original int field, and then add the default value corresponding to the char type field to perform data stream bit shift. shift.
[0064] 若所述升级目标为修改字段长度, 则根据待改动长度进行数据流的位偏移, 并 写入默认值。 [0064] If the upgrade target is to modify the length of the field, the bit offset of the data stream is performed according to the length to be changed, and the default value is written.
[0065] 在本发明实施例中, 所述修改字段长度专指 char型字符串。 例如: 若所述升级 目标为将 char型字段长度由 temp[20]改为 temp[10], 提取出的旧数据原来里边的 数据流已经有大于 10个字节的内容, 则刪除该数据, 并添加进 10字节的默认值 , 若旧数据小于等于 10个字节, 则不修改。 反之, 若所述升级目标为将 char型字 段长度由 Temp[10]改为 temp[20], 则不用修改。  [0065] In the embodiment of the present invention, the modified field length refers specifically to a char string. For example: If the upgrade target is to change the length of the char type field from temp[20] to temp[10], and the extracted data in the old data has more than 10 bytes of content, delete the data. And add the default value of 10 bytes, if the old data is less than or equal to 10 bytes, it will not be modified. Conversely, if the upgrade target is to change the char field length from Temp[10] to temp[20], no modification is required.
[0066] 此外, 需要说明的, 由于本发明实施例中在对数据库进行升级前对源数据库进 行了备份, 所以在数据库的升级过程中一旦出现错误即可利用备份的源数据库 逆向升级到旧版本的数据库。  [0066] In addition, it should be noted that, since the source database is backed up before the database is upgraded in the embodiment of the present invention, the backup source database may be reversely upgraded to the old version in the event of an error in the database upgrade process. Database.
[0067] 以上可以看出, 本发明实施例提供一种对 sqlite3型嵌入式数据库进行升级的方 法, 能够实现通过对数据库中现有的数据的提取拆分, 在无损的前提下进行数 据库的升级, 有效的完善了现有 sqlite3嵌入式数据库的不足, 补充了 sqlite3嵌入 式数据库缺失的功能, 能够使大部分使用 sqlite3型嵌入式数据库的设备均可以进 行无损升级操作, 最大程度的保护了源数据库中的数据, 简化了升级步骤、 缩 短了升级吋间, 并且极大地方便了设备的维护, 减少了维护人员的工作量。  [0067] As can be seen from the above, the embodiment of the present invention provides a method for upgrading an sqlite type 3 embedded database, which can implement an upgrade of the database by extracting and splitting existing data in the database. Effectively improve the existing sqlite3 embedded database, supplement the missing function of sqlite3 embedded database, can make most of the devices using sqlite3 embedded database can perform non-destructive upgrade operation, maximally protect the source database. The data in the simplifies the upgrade steps, shortens the upgrade time, and greatly facilitates the maintenance of the equipment, reducing the workload of maintenance personnel.
[0068] 图 3示出了本发明实施例提供的对 sqlite3型嵌入式数据库进行升级的系统的结构 框图, 该系统位于本发明实施例所述的设备中, 用于运行上述图 1~图2所示实施 例提供的方法。 为了便于说明仅仅示出了与本实施例相关的部分。  3 is a structural block diagram of a system for upgrading an sqlite3 type embedded database according to an embodiment of the present invention. The system is located in the device according to the embodiment of the present invention, and is used to run the above FIG. 1 to FIG. 2 The method provided by the illustrated embodiment. Only the parts related to the present embodiment are shown for convenience of explanation.
[0069] 参见图 3所示, 本发明实施例提供一种对 sqlite3型嵌入式数据库进行升级的系统 , 包括:  [0069] Referring to FIG. 3, an embodiment of the present invention provides a system for upgrading a sqlite3 embedded database, including:
[0070] 应用软件升级模块 1, 用于在设备上完成升级应用软件的加载并重新启动设备 [0071] 判断模块 2, 用于读取所述升级应用软件中目标数据库的版本号和所述设备内 存中源数据库的版本号, 判断所述目标数据库的版本号与所述源数据库的版本 号是否一致; [0070] The application software upgrade module 1 is configured to complete loading and restarting the upgrade application software on the device. [0071] The determining module 2 is configured to read the version number of the target database in the upgrade application software and the device. Inside a version number of the source database, determining whether the version number of the target database is consistent with the version number of the source database;
[0072] 数据库升级模块 3, 用于若不一致, 则对所述源数据库进行备份, 并调用所述 升级应用软件内嵌的与所述目标数据库的版本号和所述源数据库的版本号相匹 配的升级配置文件, 根据所述升级配置文件对所述设备内存中的所述源数据库 进行升级。  [0072] The database upgrade module 3 is configured to perform backup on the source database if inconsistency, and invoke a version number embedded in the upgrade application software to match the version number of the target database and the version number of the source database. The upgrade configuration file, the source database in the device memory is upgraded according to the upgrade configuration file.
[0073] 可选的, 所述数据库升级模块 3包括:  [0073] Optionally, the database upgrade module 3 includes:
[0074] 数据库结构逆向建立单元 31, 用于获取目标数据库的数据库结构, 根据所述目 标数据库的数据库结构和所述升级配置文件逆向建立所述源数据库的数据库结 构;  [0074] a database structure reverse establishing unit 31, configured to acquire a database structure of the target database, and inversely establish a database structure of the source database according to the database structure of the target database and the upgrade configuration file;
[0075] 数据流获取单元 32, 用于利用所述源数据库的数据库结构进行内存空间分配, 以读取所述源数据库中旧数据表的数据流;  [0075] a data stream obtaining unit 32, configured to perform memory space allocation by using a database structure of the source database, to read a data stream of the old data table in the source database;
[0076] 新数据表创建单元 33, 用于刪除所述旧数据表, 并利用所述目标数据库的数据 库结构创建新数据表; [0076] a new data table creating unit 33, configured to delete the old data table, and create a new data table by using a database structure of the target database;
[0077] 数据流位偏移处理单元 34, 用于将所述数据流恢复到所述新数据表中, 并根据 所述升级配置文件对所述新数据表中数据流的位偏移进行处理, 以生成目标数 据库。  [0077] a data stream bit offset processing unit 34, configured to restore the data stream to the new data table, and process a bit offset of the data stream in the new data table according to the upgrade configuration file. To generate the target database.
[0078] 可选的, 所述升级配置文件包括目标数据库中数据库结构以及源数据库中数据 结构的字段变化信息, 所述字段变化信息包括: 刪除字段、 添加字段、 修改字 段名称、 修改字段类型以及修改字段长度。  [0078] Optionally, the upgrade configuration file includes a database structure in the target database and field change information of the data structure in the source database, where the field change information includes: deleting a field, adding a field, modifying a field name, modifying a field type, and Modify the field length.
[0079] 可选的, 所述升级配置文件以 xml文件格式的形式内嵌于所述升级应用软件中 , 且所述升级配置文件中的每个升级目标作为一个单元以链表的形式存储, 以 便在数据库升级过程中根据所述链表顺序执行所述升级配置文件中的升级目标  [0079] Optionally, the upgrade configuration file is embedded in the upgrade application software in an xml file format, and each upgrade target in the upgrade configuration file is stored as a unit in a linked list, so that Performing the upgrade target in the upgrade configuration file according to the linked list sequence during the database upgrade process
[0080] 可选的, 所述数据流位偏移处理单元 34具体用于: [0080] Optionally, the data stream bit offset processing unit 34 is specifically configured to:
[0081] 若所述升级目标为刪除字段, 则对所述数据流按照位进行査找以获取待刪除字 段存储的目标位, 刪除所述目标位处存储的信息, 并重新进行数据位偏移; [0082] 若所述升级目标为添加字段, 则对所述数据流按照位进行査找以获取待添加字 段的添加位置, 在所述添加位置处添加对应的字段长度, 并给新添加的字段赋 默认的数据; [0081] if the upgrade target is a delete field, searching the data stream according to a bit to obtain a target bit stored in the field to be deleted, deleting information stored at the target bit, and performing data bit shift again; [0082] if the upgrade target is an add field, searching for the data stream according to a bit to obtain a word to be added Adding a position of the segment, adding a corresponding field length at the added position, and assigning default data to the newly added field;
[0083] 若所述升级目标为修改字段名称, 则不进行处理;  [0083] if the upgrade target is to modify the field name, no processing is performed;
[0084] 若所述升级目标为修改字段类型, 则计算出待修改字段位置处数据流的位偏移 量, 并刪除所述待修改字段位置处的数据流, 然后进行字段添加, 并计算出新 添加字段位置处数据流的位偏移量, 对两个位偏移量进行差值计算, 以进行位 偏移, 并在新添加字段的位置处写入默认值;  [0084] if the upgrade target is a modified field type, calculating a bit offset of the data stream at the position of the field to be modified, deleting the data stream at the position of the field to be modified, and then adding the field, and calculating The bit offset of the data stream at the newly added field position, the difference calculation between the two bit offsets to perform the bit offset, and the default value is written at the position of the newly added field;
[0085] 若所述升级目标为修改字段长度, 则根据待改动长度进行数据流的位偏移, 并 写入默认值。  [0085] If the upgrade target is to modify the length of the field, the bit offset of the data stream is performed according to the length to be changed, and the default value is written.
[0086] 需要说明的是, 本发明实施例提供的上述系统中各个模块, 由于与本发明方法 实施例基于同一构思, 其带来的技术效果与本发明方法实施例相同, 具体内容 可参见本发明方法实施例中的叙述, 此处不再赘述。  [0086] It is to be noted that the respective modules in the foregoing system provided by the embodiments of the present invention are based on the same concept as the method embodiment of the present invention, and the technical effects thereof are the same as the method embodiments of the present invention. The description in the embodiments of the present invention will not be repeated here.
[0087] 因此, 本发明实施例提供的一种对 sqlite3型嵌入式数据库进行升级的系统同样 能够实现通过对数据库中现有的数据的提取拆分, 在无损的前提下进行数据库 的升级, 有效的完善了现有 sqlite3嵌入式数据库的不足, 补充了 sqlite3嵌入式数 据库缺失的功能, 能够使大部分使用 sqlite3型嵌入式数据库的设备均可以进行无 损升级操作, 最大程度的保护了源数据库中的数据, 简化了升级步骤、 缩短了 升级吋间, 并且极大地方便了设备的维护, 减少了维护人员的工作量。  [0087] Therefore, the system for upgrading the sqlite3 embedded database provided by the embodiment of the present invention can also implement the database upgrade by using the extraction and splitting of the existing data in the database. Improve the existing sqlite3 embedded database, supplement the missing function of sqlite3 embedded database, can make most of the devices using sqlite3 embedded database can perform non-destructive upgrade operation, maximally protect the source database The data simplifies the upgrade process, shortens the upgrade time, and greatly facilitates the maintenance of the equipment, reducing the workload of maintenance personnel.
[0088] 请参考图 4, 本发明另一实施例提供的一种对 sqlite3型嵌入式数据库进行升级的 系统的结构框图。 该系统位于本发明实施例所述的设备中, 用于运行上述图 1~ 图 2所示实施例提供的方法。 为了便于说明仅仅示出了与本实施例相关的部分。  [0088] Please refer to FIG. 4, which is a structural block diagram of a system for upgrading a sqlite3 type embedded database according to another embodiment of the present invention. The system is located in the device according to the embodiment of the present invention, and is used to run the method provided in the embodiment shown in FIG. 1 to FIG. 2 above. Only the parts related to the present embodiment are shown for convenience of explanation.
[0089] 参见图 4所示, 本实施例提供一种对 sqlite3型嵌入式数据库进行升级的系统包括  [0089] Referring to FIG. 4, the embodiment provides a system for upgrading a sqlite3 embedded database, including
[0090] 处理器 (processor) 410, 通信接口 (Communications Interface) 420, 存储器 [0090] processor 410, communication interface 420, memory
(memory) 430, 总线 440。  (memory) 430, bus 440.
[0091] 处理器 410, 通信接口 420, 存储器 430通过总线 440完成相互间的通信。 [0091] The processor 410, the communication interface 420, and the memory 430 complete communication with each other through the bus 440.
[0092] 通信接口 420, 用于与外界设备, 例如, 个人电脑、 服务器等通信。 [0092] The communication interface 420 is configured to communicate with an external device, such as a personal computer, a server, or the like.
[0093] 处理器 410, 用于执行程序 431。 [0094] 具体地, 程序 431可以包括程序代码, 所述程序代码包括计算机操作指令。 [0093] The processor 410 is configured to execute the program 431. [0094] Specifically, the program 431 may include program code, the program code including computer operation instructions.
[0095] 处理器 410可能是一个中央处理器 CPU, 或者是特定集成电路 ASIC (Applicatio n Specific Integrated Circuit) , 或者是被配置成实施本发明实施例的一个或多个 集成电路。 [0095] The processor 410 may be a central processing unit CPU, or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention.
[0096] 存储器 430, 用于存放程序 431。 存储器 430可能包含高速 RAM存储器, 也可能 还包括非易失性存储器 (non-volatile memory) , 例如至少一个磁盘存储器。 程 序 431具体可以包括:  [0096] The memory 430 is configured to store the program 431. The memory 430 may include a high speed RAM memory and may also include a non-volatile memory such as at least one disk memory. The program 431 may specifically include:
[0097] 应用软件升级模块 1, 用于在设备上完成升级应用软件的加载并重新启动设备  [0097] application software upgrade module 1, used to complete the loading of the upgrade application software on the device and restart the device
[0098] 判断模块 2, 用于读取所述升级应用软件中目标数据库的版本号和所述设备内 存中源数据库的版本号, 判断所述目标数据库的版本号与所述源数据库的版本 号是否一致; [0098] The determining module 2 is configured to read a version number of the target database in the upgrade application software and a version number of the source database in the device memory, and determine a version number of the target database and a version number of the source database. Consistent;
[0099] 数据库升级模块 3, 用于若不一致, 则对所述源数据库进行备份, 并调用所述 升级应用软件内嵌的与所述目标数据库的版本号和所述源数据库的版本号相匹 配的升级配置文件, 根据所述升级配置文件对所述设备内存中的所述源数据库 进行升级。  [0099] The database upgrade module 3 is configured to perform backup on the source database if inconsistency, and invoke the version number of the target database embedded in the upgrade application software to match the version number of the source database. The upgrade configuration file, the source database in the device memory is upgraded according to the upgrade configuration file.
[0100] 所属领域的技术人员可以清楚地了解到, 为描述的方便和简洁, 上述描述的系 统、 装置和单元的具体工作过程, 可以参考前述方法实施例中的对应过程, 在 此不再赘述。  [0100] It will be apparent to those skilled in the art that, for the convenience and brevity of the description, the specific working process of the system, the device and the unit described above may refer to the corresponding process in the foregoing method embodiment, and details are not described herein again. .
[0101] 在本申请所提供的几个实施例中, 应该理解到, 所揭露的系统、 装置和方法, 可以通过其它的方式实现。 例如, 以上所描述的装置实施例仅仅是示意性的, 例如, 所述单元的划分, 仅仅为一种逻辑功能划分, 实际实现吋可以有另外的 划分方式, 例如多个单元或组件可以结合或者可以集成到另一个系统, 或一些 特征可以忽略, 或不执行。 另一点, 所显示或讨论的相互之间的耦合或直接耦 合或通信连接可以是通过一些通信接口, 装置或单元的间接耦合或通信连接, 可以是电性, 机械或其它的形式。  [0101] In the several embodiments provided by the present application, it should be understood that the disclosed system, apparatus, and method may be implemented in other manners. For example, the device embodiments described above are merely illustrative. For example, the division of the unit is only a logical function division, and the actual implementation may have another division manner, for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not executed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some communication interface, device or unit, and may be in electrical, mechanical or other form.
[0102] 所述作为分离部件说明的单元可以是或者也可以不是物理上分幵的, 作为单元 显示的部件可以是或者也可以不是物理单元, 即可以位于一个地方, 或者也可 以分布到多个网络单元上。 可以根据实际的需要选择其中的部分或者全部单元 来实现本实施例方案的目的。 [0102] The unit described as a separate component may or may not be physically distributed. The component displayed as a unit may or may not be a physical unit, that is, may be located in one place, or may be located in one place. Distributed to multiple network elements. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
[0103] 另外, 在本发明各个实施例中的各功能单元可以集成在一个处理单元中, 也可 以是各个单元单独物理存在, 也可以两个或两个以上单元集成在一个单元中。  [0103] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0104] 所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用吋, 可 以存储在一个计算机可读取存储介质中。 基于这样的理解, 本发明的技术方案 本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产 品的形式体现出来, 该计算机软件产品存储在一个存储介质中, 包括若干指令 用以使得一台计算机设备 (可以是个人计算机, 服务器, 或者网络设备等) 执 行本发明各个实施例所述方法的全部或部分步骤。 而前述的存储介质包括: u盘 [0104] The functions, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention, which is essential or contributes to the prior art, or a part of the technical solution, may be embodied in the form of a software product, which is stored in a storage medium, including The instructions are used to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: u disk
、 移动硬盘、 只读存储器 (ROM, Read-Only , mobile hard disk, read-only memory (ROM, Read-Only
Memory) 、 随机存取存储器 (RAM, Random Access Memory) 、 磁碟或者光盘 等各种可以存储程序代码的介质。  Memory, random access memory (RAM), disk or optical disk, and other media that can store program code.
[0105] 以上所述仅为本发明的较佳实施例而已, 并不用以限制本发明, 凡在本发明的 精神和原则之内所作的任何修改、 等同替换和改进等, 均应包含在本发明的保 护范围之内。 The above description is only the preferred embodiment of the present invention, and is not intended to limit the present invention, and any modifications, equivalents, and improvements made within the spirit and scope of the present invention should be included in the present invention. Within the scope of protection of the invention.

Claims

权利要求书 Claim
[权利要求 1] 一种对 sqlite3型嵌入式数据库进行升级的方法, 其特征在于, 包括: 在设备上完成升级应用软件的加载并重新启动设备;  [Claim 1] A method for upgrading an sqlite type 3 embedded database, comprising: loading and restarting the upgrade application software on the device;
读取所述升级应用软件中目标数据库的版本号和所述设备内存中源数 据库的版本号, 判断所述目标数据库的版本号与所述源数据库的版本 号是否一致;  And reading a version number of the target database in the upgrade application software and a version number of the source database in the device memory, and determining whether a version number of the target database is consistent with a version number of the source database;
若不一致, 则对所述源数据库进行备份, 并调用所述升级应用软件内 嵌的与所述目标数据库的版本号和所述源数据库的版本号相匹配的升 级配置文件, 根据所述升级配置文件对所述设备内存中的所述源数据 库进行升级。  If not, the source database is backed up, and an upgrade configuration file embedded in the upgrade application software that matches the version number of the target database and the version number of the source database is invoked, according to the upgrade configuration. The file upgrades the source database in the device memory.
[权利要求 2] 如权利要求 1所述的对 sqlite3型嵌入式数据库进行升级的方法, 其特 征在于, 根据所述升级配置文件对所述设备内存中的源数据库进行升 级具体包括:  [Claim 2] The method for upgrading the sqlite type 3 embedded database according to claim 1, wherein the upgrading the source database in the device memory according to the upgrade configuration file includes:
获取目标数据库的数据库结构, 根据所述目标数据库的数据库结构和 所述升级配置文件逆向建立所述源数据库的数据库结构;  Obtaining a database structure of the target database, and establishing a database structure of the source database in reverse according to the database structure of the target database and the upgrade configuration file;
利用所述源数据库的数据库结构进行内存空间分配, 以读取所述源数 据库中旧数据表的数据流;  Performing a memory space allocation by using a database structure of the source database to read a data stream of the old data table in the source database;
刪除所述旧数据表, 并利用所述目标数据库的数据库结构创建新数据 表;  Deleting the old data table and creating a new data table using the database structure of the target database;
将所述数据流恢复到所述新数据表中, 并根据所述升级配置文件对所 述新数据表中数据流的位偏移进行处理, 以生成目标数据库。  The data stream is restored to the new data table, and the bit offset of the data stream in the new data table is processed according to the upgrade configuration file to generate a target database.
[权利要求 3] 如权利要求 2所述的对 sqlite3型嵌入式数据库进行升级的方法, 其特 征在于, 所述升级配置文件包括目标数据库中数据库结构以及源数据 库中数据结构的字段变化信息, 所述字段变化信息包括: 刪除字段、 添加字段、 修改字段名称、 修改字段类型以及修改字段长度。  [Claim 3] The method for upgrading an sqlite type 3 embedded database according to claim 2, wherein the upgrade configuration file includes a database structure in a target database and field change information of a data structure in the source database, The field change information includes: deleting a field, adding a field, modifying a field name, modifying a field type, and modifying a field length.
[权利要求 4] 如权利要求 3所述的对 sqlite3型嵌入式数据库进行升级的方法, 其特 征在于, 所述升级配置文件以 xml文件格式的形式与所述升级应用软 件打包在一起, 且所述升级配置文件中的每个升级目标作为一个单元 以链表的形式存储, 以便在数据库升级过程中根据所述链表顺序执行 所述升级配置文件中的升级目标。 [Claim 4] The method for upgrading an sqlite3 type embedded database according to claim 3, wherein the upgrade configuration file is packaged with the upgrade application software in an xml file format, and Each upgrade target in the upgrade configuration file as a unit Stored in the form of a linked list to perform the upgrade target in the upgrade configuration file according to the linked list order during the database upgrade process.
[权利要求 5] 如权利要求 4所述的对 sqlite3型嵌入式数据库进行升级的方法, 其特 征在于, 所述根据所述升级配置文件对所述新数据表中数据流的位偏 移进行处理, 以生成目标数据库具体包括: [Claim 5] The method for upgrading an sqlite3 type embedded database according to claim 4, wherein the processing the bit offset of the data stream in the new data table according to the upgrade configuration file To generate the target database specifically includes:
若所述升级目标为刪除字段, 则对所述数据流按照位进行査找以获取 待刪除字段存储的目标位, 刪除所述目标位处存储的信息, 并重新进 行数据位偏移;  If the upgrade target is a delete field, the data stream is searched according to a bit to obtain a target bit stored in the field to be deleted, the information stored at the target bit is deleted, and the data bit offset is re-executed;
若所述升级目标为添加字段, 则对所述数据流按照位进行査找以获取 待添加字段的添加位置, 在所述添加位置处添加对应的字段长度, 并 给新添加的字段赋默认的数据;  If the upgrade target is an add field, searching for the data stream according to the bit to obtain an added position of the field to be added, adding a corresponding field length at the added position, and assigning default data to the newly added field. ;
若所述升级目标为修改字段名称, 则不进行处理; 若所述升级目标为修改字段类型, 则计算出待修改字段位置处数据流 的位偏移量, 并刪除所述待修改字段位置处的数据流, 然后进行字段 添加, 并计算出新添加字段位置处数据流的位偏移量, 对两个位偏移 量进行差值计算, 以进行位偏移, 并在新添加字段的位置处写入默认 值;  If the upgrade target is to modify the field name, no processing is performed; if the upgrade target is a modified field type, the bit offset of the data stream at the position of the field to be modified is calculated, and the position of the field to be modified is deleted. Data stream, then add the field, and calculate the bit offset of the data stream at the newly added field position, calculate the difference between the two bit offsets, perform bit offset, and position the newly added field Write the default value;
若所述升级目标为修改字段长度, 则根据待改动长度进行数据流的位 偏移, 并写入默认值。  If the upgrade target is to modify the field length, the bit offset of the data stream is performed according to the length to be changed, and the default value is written.
[权利要求 6] —种对 sqlite3型嵌入式数据库进行升级的系统, 其特征在于, 包括: 应用软件升级模块, 用于在设备上完成升级应用软件的加载并重新启 动设备;  [Claim 6] A system for upgrading a sqlite type 3 embedded database, comprising: an application software upgrade module, configured to complete loading of the upgrade application software on the device and restarting the device;
判断模块, 用于读取所述升级应用软件中目标数据库的版本号和所述 设备内存中源数据库的版本号, 判断所述目标数据库的版本号与所述 源数据库的版本号是否一致;  a judging module, configured to read a version number of the target database in the upgrade application software and a version number of the source database in the device memory, and determine whether the version number of the target database is consistent with the version number of the source database;
数据库升级模块, 用于若不一致, 则对所述源数据库进行备份, 并调 用所述升级应用软件内嵌的与所述目标数据库的版本号和所述源数据 库的版本号相匹配的升级配置文件, 根据所述升级配置文件对所述设 备内存中的所述源数据库进行升级。 a database upgrade module, configured to back up the source database if inconsistency, and invoke an upgrade configuration file embedded in the upgrade application software that matches a version number of the target database and a version number of the source database According to the upgrade configuration file, the device is configured The source database in the standby memory is upgraded.
如权利要求 6所述的对 sqlite3型嵌入式数据库进行升级的系统, 其特 征在于, 所述数据库升级模块包括: The system for upgrading a sqlite type 3 embedded database according to claim 6, wherein the database upgrade module comprises:
数据库结构逆向建立单元, 用于获取目标数据库的数据库结构, 根据 所述目标数据库的数据库结构和所述升级配置文件逆向建立所述源数 据库的数据库结构; a database structure reverse establishing unit, configured to acquire a database structure of the target database, and reversely establish a database structure of the source database according to the database structure of the target database and the upgrade configuration file;
数据流获取单元, 用于利用所述源数据库的数据库结构进行内存空间 分配, 以读取所述源数据库中旧数据表的数据流; a data stream obtaining unit, configured to perform memory space allocation by using a database structure of the source database, to read a data stream of the old data table in the source database;
新数据表创建单元, 用于刪除所述旧数据表, 并利用所述目标数据库 的数据库结构创建新数据表; a new data table creating unit, configured to delete the old data table, and create a new data table by using a database structure of the target database;
数据流位偏移处理单元, 用于将所述数据流恢复到所述新数据表中, 并根据所述升级配置文件对所述新数据表中数据流的位偏移进行处理 , 以生成目标数据库。 a data stream bit offset processing unit, configured to restore the data stream to the new data table, and process a bit offset of the data stream in the new data table according to the upgrade configuration file to generate a target database.
如权利要求 7所述的对 sqlite3型嵌入式数据库进行升级的系统, 其特 征在于, 所述升级配置文件包括目标数据库中数据库结构以及源数据 库中数据结构的字段变化信息, 所述字段变化信息包括: 刪除字段、 添加字段、 修改字段名称、 修改字段类型以及修改字段长度。 The system for upgrading an sqlite type 3 embedded database according to claim 7, wherein the upgrade configuration file includes a database structure in the target database and field change information of the data structure in the source database, and the field change information includes : Delete fields, add fields, modify field names, modify field types, and modify field lengths.
如权利要求 8所述的对 sqlite3型嵌入式数据库进行升级的系统, 其特 征在于, 所述升级配置文件以 xml文件格式的形式与所述升级应用软 件打包在一起, 且所述升级配置文件中的每个升级目标作为一个单元 以链表的形式存储, 以便在数据库升级过程中根据所述链表顺序执行 所述升级配置文件中的升级目标。 The system for upgrading an sqlite3 type embedded database according to claim 8, wherein the upgrade configuration file is packaged with the upgrade application software in an xml file format, and the upgrade configuration file is Each upgrade target is stored as a unit in the form of a linked list, so that the upgrade target in the upgrade configuration file is executed according to the linked list order during the database upgrade process.
如权利要求 9所述的对 sqlite3型嵌入式数据库进行升级的系统, 其特 征在于, 所述数据流位偏移处理单元具体用于: The system for upgrading a sqlite type 3 embedded database according to claim 9, wherein the data stream bit offset processing unit is specifically configured to:
若所述升级目标为刪除字段, 则对所述数据流按照位进行査找以获取 待刪除字段存储的目标位, 刪除所述目标位处存储的信息, 并重新进 行数据位偏移; If the upgrade target is a delete field, the data stream is searched according to a bit to obtain a target bit stored in the field to be deleted, the information stored at the target bit is deleted, and the data bit offset is re-executed;
若所述升级目标为添加字段, 则对所述数据流按照位进行査找以获取 待添加字段的添加位置, 在所述添加位置处添加对应的字段长度, 并 给新添加的字段赋默认的数据; If the upgrade target is an add field, the data stream is searched by bit to obtain Adding a field to be added, adding a corresponding field length at the added position, and assigning default data to the newly added field;
若所述升级目标为修改字段名称, 则不进行处理; If the upgrade target is to modify the field name, no processing is performed;
若所述升级目标为修改字段类型, 则计算出待修改字段位置处数据流 的位偏移量, 并刪除所述待修改字段位置处的数据流, 然后进行字段 添加, 并计算出新添加字段位置处数据流的位偏移量, 对两个位偏移 量进行差值计算, 以进行位偏移, 并在新添加字段的位置处写入默认 值; If the upgrade target is to modify the field type, calculate a bit offset of the data stream at the position of the field to be modified, delete the data stream at the position of the field to be modified, and then add the field, and calculate a newly added field. The bit offset of the data stream at the position, the difference between the two bit offsets is calculated to perform the bit offset, and the default value is written at the position of the newly added field;
若所述升级目标为修改字段长度, 则根据待改动长度进行数据流的位 偏移, 并写入默认值。 If the upgrade target is to modify the field length, the bit offset of the data stream is performed according to the length to be changed, and the default value is written.
PCT/CN2016/093106 2015-09-15 2016-08-03 Method and system for upgrading sqlite3 embedded database WO2017045491A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510585070.2 2015-09-15
CN201510585070.2A CN105224361B (en) 2015-09-15 2015-09-15 A kind of method and system upgraded to sqlite3 type embedded databases

Publications (1)

Publication Number Publication Date
WO2017045491A1 true WO2017045491A1 (en) 2017-03-23

Family

ID=54993353

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/093106 WO2017045491A1 (en) 2015-09-15 2016-08-03 Method and system for upgrading sqlite3 embedded database

Country Status (2)

Country Link
CN (1) CN105224361B (en)
WO (1) WO2017045491A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111143348A (en) * 2019-11-25 2020-05-12 三盟科技股份有限公司 Data translation method, system, computer device and readable storage medium
CN112783549A (en) * 2021-01-08 2021-05-11 东风汽车股份有限公司 Method for upgrading data version number of automobile electric control element

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105224361B (en) * 2015-09-15 2018-05-25 华讯方舟科技有限公司 A kind of method and system upgraded to sqlite3 type embedded databases
CN108614868B (en) * 2018-04-16 2021-09-17 北京酷我科技有限公司 Automatic database upgrading method
CN108845818A (en) * 2018-07-02 2018-11-20 四川长虹电器股份有限公司 A kind of smart television data upgrade processing method based on sqlite technology
CN109241071A (en) * 2018-08-23 2019-01-18 海南新软软件有限公司 A kind of Android database upgrade method, apparatus and terminal
CN109285298A (en) * 2018-09-30 2019-01-29 苏州浪潮智能软件有限公司 A kind of method for remote updating applied to bank self-help system
CN112486546A (en) * 2020-12-18 2021-03-12 上海中通吉网络技术有限公司 SQLITE database upgrading method, device, terminal and system
CN112711432B (en) * 2020-12-31 2023-04-07 北京安博通科技股份有限公司 Feature library upgrading method and device for network security equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101901237A (en) * 2009-12-04 2010-12-01 四川川大智胜软件股份有限公司 Type-Index-Value distributed database built based on SQIite
CN103916482A (en) * 2014-04-21 2014-07-09 合肥盈云信息科技有限公司 Data synchronous transmission method based on sqlite
CN103995854A (en) * 2014-05-13 2014-08-20 大唐移动通信设备有限公司 Equipment cross-version upgrading method and device
US20150006591A1 (en) * 2013-07-01 2015-01-01 Research & Business Foundation Sungkyunkwan University Memory storage apparatus, method of supporting transaction function for database, and memory system
CN105224361A (en) * 2015-09-15 2016-01-06 深圳市华讯方舟软件信息科技有限公司 A kind of method and system that sqlite3 type embedded database is upgraded

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1315043C (en) * 2004-06-24 2007-05-09 华为技术有限公司 Compatibility upgrading method of embedded programm
CN100570604C (en) * 2006-11-13 2009-12-16 中兴通讯股份有限公司 A kind of method of relation data base applications automatic upgrade
US9767110B2 (en) * 2012-06-14 2017-09-19 Ntrepid Corporation Case data visualization application
CN102945195B (en) * 2012-11-26 2015-11-18 国电南瑞科技股份有限公司 A kind of Master-standby redundancy replication method based on SQLite database
CN103810257B (en) * 2014-01-24 2018-07-13 华为技术有限公司 A kind of method, apparatus and equipment of upgrading software database
CN104102511A (en) * 2014-07-17 2014-10-15 福建星海通信科技有限公司 SQL (structured query language) Server based automatic script upgrading system and method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101901237A (en) * 2009-12-04 2010-12-01 四川川大智胜软件股份有限公司 Type-Index-Value distributed database built based on SQIite
US20150006591A1 (en) * 2013-07-01 2015-01-01 Research & Business Foundation Sungkyunkwan University Memory storage apparatus, method of supporting transaction function for database, and memory system
CN103916482A (en) * 2014-04-21 2014-07-09 合肥盈云信息科技有限公司 Data synchronous transmission method based on sqlite
CN103995854A (en) * 2014-05-13 2014-08-20 大唐移动通信设备有限公司 Equipment cross-version upgrading method and device
CN105224361A (en) * 2015-09-15 2016-01-06 深圳市华讯方舟软件信息科技有限公司 A kind of method and system that sqlite3 type embedded database is upgraded

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111143348A (en) * 2019-11-25 2020-05-12 三盟科技股份有限公司 Data translation method, system, computer device and readable storage medium
CN112783549A (en) * 2021-01-08 2021-05-11 东风汽车股份有限公司 Method for upgrading data version number of automobile electric control element

Also Published As

Publication number Publication date
CN105224361B (en) 2018-05-25
CN105224361A (en) 2016-01-06

Similar Documents

Publication Publication Date Title
WO2017045491A1 (en) Method and system for upgrading sqlite3 embedded database
US8738883B2 (en) Snapshot creation from block lists
CN103150231B (en) The method of computer booting and computer system
CN102799464B (en) Virtual machine creation method and system, virtual machine reloading method and system
US8615488B2 (en) Physical replication of database subset to improve availability and reduce resource cost in a cloud environment
WO2016165597A1 (en) Processing method and device for data storage
CN107368353B (en) Method and device for realizing hot addition of virtual machine memory
WO2016078263A1 (en) Upgrading control device and terminal, terminal upgrading method and system, and storage medium
CN111966631A (en) Mirror image file generation method, system, equipment and medium capable of being rapidly distributed
CN111258666A (en) Reading method and device of computer file, computer system and storage medium
US10642623B1 (en) Preserving firmware settings during firmware updates
CN104407890A (en) Method for starting Android system from OTG (On-The-Go) equipment
US9846621B1 (en) Disaster recovery—multiple restore options and automatic management of restored computing devices
JP2023553220A (en) Process mining for multi-instance processes
CN110908644B (en) Configuration method and device of state node, computer equipment and storage medium
CN106933604B (en) System upgrading method and device
CN109710377B (en) Method for recovering kvm virtual machine from faulty distributed storage
WO2023087622A1 (en) Virtual machine boot configuration method and apparatus, computer device, and storage medium
CN110928624A (en) Cloud desktop calling method and device for user terminal and terminal
CN112860376B (en) Snapshot chain manufacturing method and device, electronic equipment and storage medium
CN110704249A (en) Method, device and system for ensuring application consistency
CN113609075A (en) Method, system, storage medium and equipment for creating snapshot
CN111966388A (en) Space-saving mirror image version update management method, device, equipment and medium
CN111240895A (en) OpenStack-oriented node batch backup system method
CN115576743B (en) Operating system recovery method, operating system recovery device, computer equipment and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16845605

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16845605

Country of ref document: EP

Kind code of ref document: A1