CN111241064B - Database configuration file processing method, device and storage medium - Google Patents

Database configuration file processing method, device and storage medium Download PDF

Info

Publication number
CN111241064B
CN111241064B CN202010027927.XA CN202010027927A CN111241064B CN 111241064 B CN111241064 B CN 111241064B CN 202010027927 A CN202010027927 A CN 202010027927A CN 111241064 B CN111241064 B CN 111241064B
Authority
CN
China
Prior art keywords
database
configuration
configuration file
file
data
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN202010027927.XA
Other languages
Chinese (zh)
Other versions
CN111241064A (en
Inventor
白肖
卫宣安
姜坤
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Genew Technologies Co Ltd
Original Assignee
Shenzhen Genew Technologies Co Ltd
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 Shenzhen Genew Technologies Co Ltd filed Critical Shenzhen Genew Technologies Co Ltd
Priority to CN202010027927.XA priority Critical patent/CN111241064B/en
Publication of CN111241064A publication Critical patent/CN111241064A/en
Application granted granted Critical
Publication of CN111241064B publication Critical patent/CN111241064B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases

Abstract

The invention provides a processing method, a device and a storage medium for database configuration files, which comprise the following steps: creating a database configuration file and storing the database configuration file to a corresponding path; writing or loading configuration data into the database configuration file; and if the target item operation event in the configuration data is detected, storing the operated target item in the database configuration file. By creating the database configuration file, which is equivalent to creating a small database, the invention does not need to re-write or save all data in the database when modifying, but only needs to save modified items, thereby improving the efficiency of modifying the configuration file.

Description

Database configuration file processing method, device and storage medium
Technical Field
The present invention relates to the field of configuration files, and in particular, to a method, an apparatus, and a storage medium for processing a database configuration file.
Background
The running of a plurality of existing service software can have configuration files, the configuration files can be loaded and read when the software is started, and the configuration files can be written when the software runs or ends. The existing configuration files have various formats, and are commonly in XML file format, JSON file format, binary file format and INI file format. Since these configuration files are directly created locally, when a configuration in a configuration file needs to be modified, all configuration data needs to be rewritten or saved into the configuration file, i.e. all configuration data is saved again, and only the modified item cannot be saved, which results in lower efficiency of modifying the configuration file.
Accordingly, the prior art has drawbacks and needs to be improved and developed.
Disclosure of Invention
The invention aims to solve the technical problem that the efficiency of modifying configuration files in the prior art is low by providing a processing method, a device and a storage medium for database configuration files aiming at the defects in the prior art.
The technical scheme adopted for solving the technical problems is as follows:
a method for processing a database configuration file, comprising:
creating a database configuration file and storing the database configuration file to a corresponding path;
writing or loading configuration data into the database configuration file;
and if the target item operation event in the configuration data is detected, storing the operated target item in the database configuration file.
Further, the step of creating a database configuration file and saving the database configuration file to a corresponding path specifically includes:
and referring to a dynamic link library based on database encapsulation, creating a database configuration file, and storing the database configuration file to a corresponding path.
Further, if it is detected that the target item operation event occurs in the configuration data, the step of storing the operated target item in the database configuration file specifically includes:
if an operation event of adding data to the target item occurs in the configuration data is detected, the database configuration file stores the target item added with the data;
if an operation event of modifying data of the target item in the configuration data is detected, storing the modified data of the target item in the database configuration file;
and if the operation event of deleting the data of the target item in the configuration data is detected, storing the target item after deleting the data in the database configuration file.
Further, the database is a slit database.
Further, the step of packaging the dynamic link library specifically includes:
constructing a configuration dictionary based on the Sqlite database, and creating or loading a database file with a specific extension;
and encapsulating sentences corresponding to the loading operation, the adding or modifying operation and the deleting operation in the database file to form an encapsulated dynamic link library.
Further, the step of constructing a configuration dictionary based on the Sqlite database and creating or loading the database file with the specific extension specifically includes:
based on the Sqlite database, constructing a configuration dictionary, connecting with a preset Sqlite tool class, and creating or loading a database file with an extension corresponding to the preset Sqlite tool class;
if the connection is successful, a configuration information table is created in the database file.
Further, the steps of encapsulating the sentences corresponding to the loading operation, the adding or modifying operation and the deleting operation in the database file to form an encapsulated dynamic link library specifically comprise:
checking whether the structure of the configuration information table is correct;
if the operation is correct, sentences corresponding to the loading operation, the adding or modifying operation and the deleting operation are packaged in the configuration information table to form a packaged dynamic link library.
Further, the step of checking whether the configuration information table is correct further includes:
if not, continuously using a preset Sqlite tool class to create a configuration information table;
and encapsulating sentences corresponding to the loading operation, the adding or modifying operation and the deleting operation in the configuration information table to form an encapsulated dynamic link library.
The invention also provides a device, which comprises a memory, a processor and a processing program of the database configuration file stored in the memory and capable of running on the processor, wherein the processing program of the database configuration file realizes the steps of the processing method of the database configuration file when being executed by the processor.
The present invention also provides a storage medium storing a computer program executable for implementing a method of processing a database profile as described above.
The invention provides a processing method, a device and a storage medium for database configuration files, which comprise the following steps: creating a database configuration file and storing the database configuration file to a corresponding path; writing or loading configuration data into the database configuration file; and if the target item operation event in the configuration data is detected, storing the operated target item in the database configuration file. By creating the database configuration file, which is equivalent to creating a small database, the invention does not need to re-write or save all data in the database when modifying, but only needs to save modified items, thereby improving the efficiency of modifying the configuration file.
Drawings
FIG. 1 is a flowchart of a method for processing a database profile according to a preferred embodiment of the present invention.
FIG. 2 is a flow chart of the encapsulation of a dynamic link library in a preferred embodiment of the method for processing a database profile according to the present invention.
FIG. 3 is a flowchart illustrating the operation of the database profile in a preferred embodiment of the method for processing database profiles according to the present invention.
Fig. 4 is a functional block diagram of a preferred embodiment of the apparatus of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more clear and clear, the present invention will be further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
A user (generally referred to as a person who develops application software) needs to complete the development of the corresponding application software through creation or modification of a configuration file. In the existing modification mode, a user directly creates a local file to form a configuration file, and if the data is modified, all the data in the configuration file needs to be saved again, so that the efficiency is low. The invention creates the database configuration file by utilizing the database, so that a user creates a small database when creating the configuration file, because the changed data items in the database can be saved, and when saving, only the changed item parts can be saved without saving all the data again. Therefore, the existing way to create the configuration file locally does not achieve the effect of the present invention.
Referring to fig. 1, fig. 1 is a flowchart of a method for processing a database configuration file according to the present invention. As shown in fig. 1, the method for processing a database configuration file according to an embodiment of the present invention includes the following steps:
s100, creating a database configuration file and storing the database configuration file to a corresponding path;
in one implementation, the step S100 specifically includes:
and referring to a dynamic link library based on database encapsulation, creating a database configuration file, and storing the database configuration file to a corresponding path.
In the invention, the database configuration file is equivalent to a small database, and the data stored in the database does not need to be rewritten or stored when being modified, but only needs to store modified items, thereby improving the efficiency of modifying the configuration file. Preferably, the database is a Sqlite database. The Sqlite database is an embedded library and implements a zero configuration, server-less and transactional SQL database engine. The dynamic link library (Dynamic Link Library) is a DLL library, which is a library containing code and data that can be used by multiple programs simultaneously. If the path saved by the database configuration file exists before, the path is still saved into the previous path; if not, automatically creating a path saved by the database configuration file.
S200, writing or loading configuration data into the database configuration file.
That is, when there is no configuration data in the dynamic link library, the user is required to write the configuration data and save it. When the configuration data exists in the dynamic link library, the existing configuration data is directly loaded.
Specifically, whether the database configuration file is successfully created is judged, if yes, configuration data are written or loaded into the database configuration file.
S300, if the occurrence of a target item operation event in the configuration data is detected, the database configuration file stores the operated target item.
Specifically, the target item refers to an item to be changed. This step is the relevant operation of the configuration. When the user needs to change the configuration data in the database configuration file, the database configuration file is opened in the file path, corresponding operation is carried out, and finally, only the changed target item is needed to be saved.
Further, the step S300 specifically includes:
s310, if detecting that the operation event of adding the data to the target item occurs in the configuration data, storing the added data target item in the database configuration file
S320, if an operation event of modifying data of the target item in the configuration data is detected, storing the modified data of the target item in the database configuration file;
s330, if the operation event of deleting the data of the target item in the configuration data is detected, the database configuration file stores the target item after deleting the data.
That is, the user can perform operations such as adding, modifying and deleting configuration data, and after the operations, the database configuration file only needs to store the target item, so that the changing efficiency of the configuration file is improved. Finally, judging whether the operation is successful, if so, returning an operation result; if not, returning an operation failure error code. Judging whether to continue operation, if so, performing the next operation, and if not, ending.
In one implementation, the step of packaging the dynamic link library specifically includes:
s10, constructing a configuration dictionary based on a Sqlite database, and creating or loading a database file with a specific extension;
s20, encapsulating sentences corresponding to loading operation, adding or modifying operation and deleting operation in the database file to form an encapsulated dynamic link library.
Further, the step S10 specifically includes:
s11, constructing a configuration dictionary based on a Sqlite database, connecting with a preset Sqlite tool class, and creating or loading a database file with an extension corresponding to the preset Sqlite tool class;
and S12, if the connection is successful, creating a configuration information table in the database file.
Specifically, the method relies on a Sqlite database to create dictionary ActiveRecorddictionary, inherits from the dictionary < string, string >, IREAdOnlydictionary < string, string >; a database file with a specific extension is created or loaded, e.g. ending in ard. That is, the specified ard database file is loaded, and if the file does not exist, the database file is automatically created.
Further, the step S20 specifically includes:
s21, checking whether the structure of the configuration information table is correct;
s22, if the statement is correct, the statement corresponding to the loading operation, the adding or modifying operation and the deleting operation is packaged in the configuration information table, and a packaged dynamic link library is formed.
Further, the step S21 further includes:
s23, if not, continuously using a preset Sqlite tool class to create a configuration information table;
s24, encapsulating sentences corresponding to loading operation, adding or modifying operation and deleting operation in the configuration information table to form an encapsulated dynamic link library.
Two fields exist in the configuration information table: key and Value. Key is a unique primary Key field, a field type char (255) corresponds to the Key of the database file; the Value is the Value of the corresponding database file, and the field type varchar. Acquiring configuration information requires execution of a select statement; adding or modifying a configuration requires execution of insert or replace into sql statements; adding or ignoring configuration only requires execution of insert or Ignore into sql statements; deleting the configuration requires executing the delete sql statement.
Specifically, the invention comprises three sentences corresponding to the operations, namely, firstly, loading configuration data sets into an ActiveRecorddictionary, namely, executing a select sql sentence; second, add or modify configuration, i.e., execute insert or replace statements; third, the configuration is deleted, i.e., the delete sql statement is executed.
When in use, a user only needs to refer to the packaged dynamic link library, create a database file ending with ard, and then perform related operations.
In one implementation, as shown in FIG. 2, the encapsulation steps for the dynamic link library are as follows:
a1, constructing a configuration dictionary based on a Sqlite database;
a2, connecting with a preset Sqlite tool class to form a ard database file;
a3, judging whether the connection is successful, if so, creating a configuration information table in the ard database file;
further, if the connection is unsuccessful, judging whether the ard database file does not exist; if yes, creating a database file by using a preset Sqlite tool class, and returning to the step A2; if not, returning to the connection error code, selecting whether to reconnect, and if so, returning to the step A2.
A4, checking whether the structure of the configuration information table is correct; if yes, encapsulating sentences corresponding to loading operation, adding or modifying operation and deleting operation in the configuration information table;
further, if the configuration information table is incorrect in structure, the configuration information table is continuously created by using a preset Sqlite tool class, and sentences corresponding to loading operation, adding or modifying operation and deleting operation are packaged in the configuration information table.
And A5, judging whether all the operations are successful, and if so, forming a packaged dynamic link library.
In addition, after each operation, judging whether the operation is successful, if so, returning an operation result and judging whether to continue the operation; if the operation is unsuccessful, returning an operation failure error code, and judging whether to continue the operation. If the operation is continued, the next operation is performed, and if the operation is not continued, the operation is ended.
As shown in fig. 3, the database configuration file operates as follows:
b1, referring to a dynamic link library based on database encapsulation, creating a database configuration file, and storing the database configuration file to a corresponding path;
b2, judging whether the database configuration file is successfully created, if so, writing or loading configuration data into the database configuration file;
in addition, if the creation is unsuccessful, an error code is returned.
B3, judging whether the writing or loading of the configuration data is successful, if yes, detecting that a target item operation event occurs in the configuration data;
in addition, if the writing or loading of the configuration data is unsuccessful, an error code is returned.
And B4, if a target item operation event occurs in the configuration data and the operation is successful, storing the operated target item by the database configuration file.
That is, when a target item operation event occurs in the configuration data, judging whether the operation is successful, if so, returning an operation result, and storing the operated target item; if not, returning an operation failure error code. And finally, judging whether to continue operation, if so, performing the next operation, and if not, ending.
As shown in fig. 4, the present invention further provides an apparatus, including a memory 20, a processor 10, and a processing program of a database profile stored in the memory 20 and capable of running on the processor 10, where the processing program of the database profile implements the steps of the processing method of the database profile as described above when executed by the processor 10; as described in detail above.
The present invention also provides a storage medium storing a computer program executable for implementing a method of processing a database profile as described above; as described in detail above.
In summary, the method, device and storage medium for processing database configuration files disclosed by the invention comprise the following steps: creating a database configuration file and storing the database configuration file to a corresponding path; writing or loading configuration data into the database configuration file; and if the target item operation event in the configuration data is detected, storing the operated target item in the database configuration file. By creating the database configuration file, which is equivalent to creating a small database, the invention does not need to re-write or save all data in the database when modifying, but only needs to save modified items, thereby improving the efficiency of modifying the configuration file.
It is to be understood that the invention is not limited in its application to the examples described above, but is capable of modification and variation in light of the above teachings by those skilled in the art, and that all such modifications and variations are intended to be included within the scope of the appended claims.

Claims (6)

1. A method for processing a database configuration file, comprising:
creating a database configuration file and storing the database configuration file to a corresponding path;
writing or loading configuration data into the database configuration file;
if the occurrence of a target item operation event in the configuration data is detected, storing the operated target item in the database configuration file;
the step of creating the database configuration file and storing the database configuration file to the corresponding path specifically comprises the following steps:
a dynamic link library based on database encapsulation is referenced, a database configuration file is created, and the database configuration file is stored to a corresponding path;
the database is a Sqlite database;
the packaging step of the dynamic link library specifically comprises the following steps:
based on the Sqlite database, constructing a configuration dictionary, connecting with a preset Sqlite tool class, and creating or loading a database file with an extension corresponding to the preset Sqlite tool class;
if the connection is successful, a configuration information table is created in the database file;
encapsulating sentences corresponding to loading operation, adding or modifying operation and deleting operation in the database file to form an encapsulated dynamic link library;
the database file is a ard database file.
2. The method for processing a database profile according to claim 1, wherein if a target item operation event is detected in the configuration data, the step of storing the operated target item in the database profile specifically includes:
if an operation event of adding data to the target item occurs in the configuration data is detected, the database configuration file stores the target item added with the data;
if an operation event of modifying data of the target item in the configuration data is detected, storing the modified data of the target item in the database configuration file;
and if the operation event of deleting the data of the target item in the configuration data is detected, storing the target item after deleting the data in the database configuration file.
3. The method for processing a database configuration file according to claim 1, wherein the step of encapsulating sentences corresponding to the loading operation, the adding or modifying operation, and the deleting operation in the database file to form an encapsulated dynamic link library specifically comprises:
checking whether the structure of the configuration information table is correct;
if the operation is correct, sentences corresponding to the loading operation, the adding or modifying operation and the deleting operation are packaged in the configuration information table to form a packaged dynamic link library.
4. A method of processing a database profile according to claim 3, further comprising, after the step of checking whether the configuration information table is structured correctly:
if not, continuously using a preset Sqlite tool class to create a configuration information table;
and encapsulating sentences corresponding to the loading operation, the adding or modifying operation and the deleting operation in the configuration information table to form an encapsulated dynamic link library.
5. A database profile processing device comprising a memory, a processor and a database profile processing program stored on the memory and executable on the processor, the database profile processing program when executed by the processor implementing the steps of the database profile processing method according to any one of claims 1 to 4.
6. A storage medium storing a computer program executable by a processor for implementing a method of processing a database profile according to any one of claims 1-4.
CN202010027927.XA 2020-01-10 2020-01-10 Database configuration file processing method, device and storage medium Active CN111241064B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010027927.XA CN111241064B (en) 2020-01-10 2020-01-10 Database configuration file processing method, device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010027927.XA CN111241064B (en) 2020-01-10 2020-01-10 Database configuration file processing method, device and storage medium

Publications (2)

Publication Number Publication Date
CN111241064A CN111241064A (en) 2020-06-05
CN111241064B true CN111241064B (en) 2023-11-03

Family

ID=70868848

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010027927.XA Active CN111241064B (en) 2020-01-10 2020-01-10 Database configuration file processing method, device and storage medium

Country Status (1)

Country Link
CN (1) CN111241064B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112235124B (en) * 2020-08-14 2023-03-24 浙江三维利普维网络有限公司 Method and device for configuring pico-cell, storage medium and electronic device
CN111737018B (en) * 2020-08-26 2020-12-22 腾讯科技(深圳)有限公司 ZooKeeper configuration file storage processing method, device, equipment and medium thereof

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102323940A (en) * 2011-09-01 2012-01-18 中兴通讯股份有限公司 Configuration platform implementation method, configuration platform and system based on database
US8255357B1 (en) * 2006-04-24 2012-08-28 Sprint Communications Company L.P. Systems and methods of configuration management for enterprise software
CN103488677A (en) * 2013-07-22 2014-01-01 广州唯品会信息科技有限公司 Project configuration method and device
CN106326411A (en) * 2016-08-23 2017-01-11 北京奇艺世纪科技有限公司 Configuration change method and device
CN108121542A (en) * 2017-11-17 2018-06-05 广东睿江云计算股份有限公司 A kind of collocation method of the SQL statement based on MyBatis, system
CN110019517A (en) * 2017-11-14 2019-07-16 顺丰科技有限公司 A kind of database middleware Dynamic Configuration, system, equipment, storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8255357B1 (en) * 2006-04-24 2012-08-28 Sprint Communications Company L.P. Systems and methods of configuration management for enterprise software
CN102323940A (en) * 2011-09-01 2012-01-18 中兴通讯股份有限公司 Configuration platform implementation method, configuration platform and system based on database
CN103488677A (en) * 2013-07-22 2014-01-01 广州唯品会信息科技有限公司 Project configuration method and device
CN106326411A (en) * 2016-08-23 2017-01-11 北京奇艺世纪科技有限公司 Configuration change method and device
CN110019517A (en) * 2017-11-14 2019-07-16 顺丰科技有限公司 A kind of database middleware Dynamic Configuration, system, equipment, storage medium
CN108121542A (en) * 2017-11-17 2018-06-05 广东睿江云计算股份有限公司 A kind of collocation method of the SQL statement based on MyBatis, system

Also Published As

Publication number Publication date
CN111241064A (en) 2020-06-05

Similar Documents

Publication Publication Date Title
KR101036679B1 (en) Test case inheritance controlled via attributes
JP4878715B2 (en) Method, computer system and computer readable recording medium for patching applications that do not conform to operating system
US7774772B2 (en) Method and apparatus to perform an application software migration
US8484638B2 (en) Infrastructure for the automation of the assembly of schema maintenance scripts
US8954939B2 (en) Extending a development environment
US7509655B2 (en) Integration of workflow and rules
CN111241064B (en) Database configuration file processing method, device and storage medium
CN110555770B (en) Block chain world state checking and recovering method based on incremental hash
JP4298700B2 (en) Method and computer-readable recording medium for inspecting and storing electronic documents
EP1960910B1 (en) System and method for deploying an sql procedure
CN1976320B (en) Data access control method and system
US20030088572A1 (en) Method, computer program product, and system for unloading a hierarchical database utilizing segment specific selection critera
CN110889574A (en) Uncertainty factor detection device, method and medium for intelligent contract
CN111190768B (en) Database execution error recovery method, database access method and device
CN114816247A (en) Logic data acquisition method and device
US20020198860A1 (en) Method, computer program product, and system for modifying populated databases utilizing a reload utility
US8856069B2 (en) Combined save and validation logic
CN111930387A (en) Integration method and device of integration package, electronic equipment and storage medium
CN116700763B (en) Version upgrading method and device for Clickhouse database
CN112817580B (en) Data processing method and device, electronic equipment and storage medium
CN111563006B (en) Data processing method, intelligent terminal and storage medium
CN116991427B (en) Application compiling method and device, computing equipment and storage medium
US20230139969A1 (en) Idempotent resource management system provisioning
US20110246870A1 (en) Validating markup language schemas and semantic constraints
US8453108B1 (en) Static, configurable kernel interface

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant