CN107622070B - Database management method and device - Google Patents

Database management method and device Download PDF

Info

Publication number
CN107622070B
CN107622070B CN201610560942.4A CN201610560942A CN107622070B CN 107622070 B CN107622070 B CN 107622070B CN 201610560942 A CN201610560942 A CN 201610560942A CN 107622070 B CN107622070 B CN 107622070B
Authority
CN
China
Prior art keywords
database
parameters
statement
splitting
mapping relation
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
CN201610560942.4A
Other languages
Chinese (zh)
Other versions
CN107622070A (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 Lan You Technology Co Ltd
Original Assignee
Shenzhen Lan You Technology 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 Lan You Technology Co Ltd filed Critical Shenzhen Lan You Technology Co Ltd
Priority to CN201610560942.4A priority Critical patent/CN107622070B/en
Publication of CN107622070A publication Critical patent/CN107622070A/en
Application granted granted Critical
Publication of CN107622070B publication Critical patent/CN107622070B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a database management method and a device, wherein the method comprises the following steps: defining operation statements including adding, deleting, modifying, searching and storing in the database; establishing a mapping relation between the defined operation statement and the corresponding database API; splitting the operation statement into a plurality of parameters and a database operation type according to the mapping relation; and respectively inputting a plurality of values of the parameters, and calling a database API according to the values of the parameters and the operation type of the database. The beneficial effects of the invention are as follows: by redefining the database operation statements and splitting the database operation statements, the efficiency of compiling programs by the database is improved.

Description

Database management method and device
Technical Field
The invention relates to the technical field of database management, in particular to a database management method and device.
Background
The operation database is usually an API (application programming interface) for querying or updating data in the database by calling the operation database provided by a computer language. The existing solution for operating a database is usually to call an API provided by a computer language to access the database, to query or update the database, and to return the result. Therefore, the existing scheme for calling the database API cannot reuse codes for operating the database. If the language is a compiling type language, debugging codes is inconvenient, and the codes need to be recompiled after the codes are changed every time, so that the development efficiency is not high.
Disclosure of Invention
The technical problem to be solved by the present invention is to provide a database management method and apparatus, aiming at the problem of low API call efficiency of the database in the prior art.
The technical scheme adopted by the invention for solving the technical problems is as follows:
in one aspect, a database management method is constructed, comprising:
defining operation statements including adding, deleting, modifying, searching and storing in the database;
establishing a mapping relation between the defined operation statement and the corresponding database API;
splitting the operation statement into a plurality of parameters and a database operation type according to the mapping relation;
and respectively inputting a plurality of values of the parameters, and calling a database API according to the values of the parameters and the operation type of the database.
In the database management method of the present invention, the step of establishing the mapping relationship between the defined operation statement and the corresponding database API includes the following substeps:
establishing a mapping relation between the defined operation statement and the corresponding database API;
acquiring a script corresponding to a database management task item according to the mapping relation;
executing the script on the database to dynamically operate the database.
In the database management method of the present invention, the step of splitting the operation statement into a plurality of parameters and a database operation type according to the mapping relationship includes the following substeps:
splitting the character string to be analyzed according to the mapping relation, so as to obtain a database operation statement array;
and traversing the database operation statement array to split the operation statement into a plurality of parameters and database operation types.
In the database management method according to the present invention, the step of inputting the values of the parameters and calling the database API according to the values of the parameters and the database operation type further includes:
and calling a database API (application programming interface) to query the database, and storing a database return result into a variable.
In the database management method of the present invention, the step of traversing the database operation statement array to split the operation statement into a plurality of parameters and a database operation type includes the steps of:
s321, detecting whether unprocessed operation statements exist or not, and if yes, taking down one operation statement, wherein the database operation statement array comprises a plurality of operation statements;
and S322, splitting the operation statement into a plurality of parameters and database operation types, and returning to the step S321 until the operation statement processing is completed.
In another aspect, there is provided a database management apparatus including:
the definition unit is used for defining operation statements including addition, deletion, modification, search and storage in the database;
the mapping establishing unit is used for establishing the mapping relation between the defined operation statement and the corresponding database API;
the splitting unit is used for splitting the operation statement into a plurality of parameters and database operation types according to the mapping relation;
and the calling unit is used for respectively inputting a plurality of values of the parameters and calling the database API according to the values of the parameters and the operation type of the database.
In the database management apparatus of the present invention, the mapping establishing unit includes:
the mapping establishing module is used for establishing the mapping relation between the defined operation statement and the corresponding database API;
the script obtaining module is used for obtaining a script corresponding to the database management task item according to the mapping relation;
and the script execution module is used for executing the script on the database so as to dynamically operate the database.
In the database management apparatus of the present invention, the splitting unit includes:
the character string splitting module is used for splitting the character string to be analyzed according to the mapping relation so as to obtain a database operation statement array;
and the array traversing module is used for traversing the database operation statement array so as to split the operation statement into a plurality of parameters and database operation types.
In the database management apparatus of the present invention, the invoking unit is further configured to:
and calling a database API (application programming interface) to query the database, and storing a database return result into a variable.
In the database management apparatus of the present invention, the array traversal module includes:
the statement detection submodule is used for detecting whether unprocessed operation statements exist or not, and if the unprocessed operation statements exist, taking down one operation statement, wherein the database operation statement array comprises a plurality of operation statements;
and the splitting sub-module is used for splitting the operation statement into a plurality of parameters and database operation types.
The database management method and the database management device have the following beneficial effects: by redefining the database operation statements and splitting the database operation statements, the efficiency of compiling programs by the database is improved.
Drawings
FIG. 1 is a flow chart of a database management method provided by the present invention;
fig. 2 is a block diagram of a database management apparatus according to the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The invention provides a database management method and a database management device, and aims to improve the efficiency of compiling a program by redefining and splitting database operation statements. The invention specifically comprises two parts, wherein one part is a database operation statement and is used for compiling a dynamic statement for operating the database; the second part is a parsing engine which parses the database operation statements, invokes the database API, and returns the results.
Referring to fig. 1, fig. 1 is a flowchart of a database management method provided by the present invention, where the database management method includes steps S1-S4:
s1, defining operation sentences including adding, deleting, modifying, searching and storing in the database; specifically, the defined operation statements are as follows:
1、GetData(tableName,columnNames,filterCondition,recordCount,resultVarName),
data is queried from a database.
Description of the parameters: tableName: the name of the database table. columnNames: a list of database fields. filterCondition: the filtering condition of the query. recordCount: the number of records returned is set. ResultVarName: and storing the variable name of the database query result.
2. InsertData (tableName, idFieldName, idVarName, idType, fieldandValueStr, resultVarName), inserts data into the database.
Description of the parameters: tableName: database table name, idFieldName: primary key field names. idVarName: and the primary key variable name is used for storing the primary key value. idType: and generating a primary key value. fieldAndValueStr: a string of fields and corresponding values merged together. ResultVarName: and saving the variable name of the insertion result.
3. UpdateData (tableName, fieldAndValueStr, updateCondition, resultVarName), changes the database.
Description of the parameters: tableName: database table name, fieldAndValueStr: a string of fields and corresponding values merged together. updateCondition: the conditions are changed. ResultVarName: and saving the variable name of the change result.
4. DeleteData (tableName, deleteCondition, resultVarName), deletes data in the database.
Description of the parameters: tableName: database table name, deleteCondition: the condition is deleted. ResultVarName: and saving the variable name of the deletion result.
5. ExecuteSQL (outputVarType, outputVarName, sqlType, spNameOrSql, spOrSqlPara, resultVarName), executes SQL statements or stores procedures.
Description of the parameters: output VarType: storing SQL statements or storing variable types of process execution results. outputVarName: storing SQL statements or storing variable names of the process execution results. sqlType: type, SQL, or stored procedure. spNameOrSql: the procedure name or SQL statement is stored. sporSqlPara: parameters of the procedure or SQL statement are stored. ResultVarName: the variable name of whether execution was successful is saved.
S2, establishing a mapping relation between the defined operation statement and the corresponding database API; the step S2 includes sub-steps S21-S23:
s21, establishing a mapping relation between the defined operation statement and the corresponding database API;
s22, acquiring a script corresponding to the database management task item according to the mapping relation;
and S23, executing the script on the database to dynamically operate the database.
S3, splitting the operation statement into a plurality of parameters and database operation types according to the mapping relation; the step S3 includes sub-steps S31-S32:
s31, splitting the character string to be analyzed according to the mapping relation, and thus obtaining a database operation statement array;
and S32, traversing the database operation statement array to split the operation statement into a plurality of parameters and database operation types. The step S32 includes sub-steps S321-S322:
s321, detecting whether unprocessed operation statements exist or not, and if yes, taking down one operation statement, wherein the database operation statement array comprises a plurality of operation statements;
and S322, splitting the operation statement into a plurality of parameters and database operation types, and returning to the step S321 until the operation statement processing is completed.
And S4, respectively inputting a plurality of values of the parameters, and calling a database API according to the values of the parameters and the operation type of the database. And calling a database API (application programming interface) to query the database, and storing a database return result into a variable. And calling the corresponding database API according to the operation type of the database, such as InsertData or GetData, and the value of the parameter input by the user, and taking the returned result as the variable value.
In summary, the present invention first reads a character string including a dynamic database statement, splits the character string to obtain one or more database operation statements, processes each database operation statement in sequence, splits the database operation statement into a database operation type and a plurality of parameters, and then calls an API provided by a computer language to access the database and returns a result.
Referring to fig. 2, fig. 2 is a block diagram of a database management apparatus 100 according to the present invention, where the database management apparatus 100 is implemented by setting a corresponding program in a system, and the database management apparatus 100 includes a definition unit 1, a mapping establishment unit 2, a splitting unit 3, and a calling unit 4.
The definition unit 1 is used for defining operation statements including addition, deletion, modification, search and storage in a database;
the mapping establishing unit 2 is used for establishing a mapping relation between the defined operation statement and the corresponding database API;
the splitting unit 3 is configured to split the operation statement into a plurality of parameters and a database operation type according to the mapping relationship;
the calling unit 4 is configured to input values of the parameters, and call a database API according to the values of the parameters and the database operation type.
Preferably, the mapping establishing unit 2 includes:
the mapping establishing module is used for establishing the mapping relation between the defined operation statement and the corresponding database API;
the script obtaining module is used for obtaining a script corresponding to the database management task item according to the mapping relation;
and the script execution module is used for executing the script on the database so as to dynamically operate the database.
Preferably, the splitting unit 3 includes:
the character string splitting module is used for splitting the character string to be analyzed according to the mapping relation so as to obtain a database operation statement array;
and the array traversing module is used for traversing the database operation statement array so as to split the operation statement into a plurality of parameters and database operation types.
Preferably, the invoking unit 4 is further configured to:
and calling a database API (application programming interface) to query the database, and storing a database return result into a variable.
Preferably, the array traversal module includes:
the statement detection submodule is used for detecting whether unprocessed operation statements exist or not, and if the unprocessed operation statements exist, taking down one operation statement, wherein the database operation statement array comprises a plurality of operation statements;
and the splitting sub-module is used for splitting the operation statement into a plurality of parameters and database operation types.
Various operations of embodiments are provided herein. In one embodiment, the one or more operations described may constitute computer readable instructions stored on one or more computer readable media, which when executed by an electronic device, will cause the computing device to perform the operations described. The order in which some or all of the operations are described should not be construed as to imply that these operations are necessarily order dependent. Those skilled in the art will appreciate alternative orderings having the benefit of this description. Moreover, it should be understood that not all operations are necessarily present in each embodiment provided herein.
Also, as used herein, the word "preferred" is intended to serve as an example, instance, or illustration. Any aspect or design described herein as "preferred" is not necessarily to be construed as advantageous over other aspects or designs. Rather, use of the word "preferred" is intended to present concepts in a concrete fashion. The term "or" as used in this application is intended to mean an inclusive "or" rather than an exclusive "or". That is, unless specified otherwise or clear from context, "X employs A or B" is intended to include either of the permutations as a matter of course. That is, if X employs A; b is used as X; or X employs both A and B, then "X employs A or B" is satisfied in any of the foregoing examples.
Also, although the disclosure has been shown and described with respect to one or an implementation, equivalent alterations and modifications will occur to others skilled in the art based upon a reading and understanding of this specification and the annexed drawings. The present disclosure includes all such modifications and alterations, and is limited only by the scope of the appended claims. In particular regard to the various functions performed by the above described components (e.g., elements, resources, etc.), the terms used to describe such components are intended to correspond, unless otherwise indicated, to any component which performs the specified function of the described component (e.g., that is functionally equivalent), even though not structurally equivalent to the disclosed structure which performs the function in the herein illustrated exemplary implementations of the disclosure. In addition, while a particular feature of the disclosure may have been disclosed with respect to only one of several implementations, such feature may be combined with one or other features of the other implementations as may be desired and advantageous for a given or particular application. Furthermore, to the extent that the terms "includes," has, "" contains, "or variants thereof are used in either the detailed description or the claims, such terms are intended to be inclusive in a manner similar to the term" comprising.
Each functional unit in the embodiments of the present invention may be integrated into one processing module, or each unit may exist alone physically, or two or more units are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may also be stored in a computer readable storage medium. The storage medium mentioned above may be a read-only memory, a magnetic or optical disk, etc. Each apparatus or system described above may execute the storage method in the corresponding method embodiment.
In summary, although the present invention has been described with reference to the preferred embodiments, the above-described preferred embodiments are not intended to limit the present invention, and those skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention, therefore, the scope of the present invention shall be determined by the appended claims.

Claims (2)

1. A database management method, comprising:
defining operation statements including adding, deleting, modifying, searching and storing in the database;
establishing a mapping relation between the defined operation statement and the corresponding database API; the step of establishing a mapping relationship between the defined operation statements and the corresponding database API comprises the following substeps: establishing a mapping relation between the defined operation statement and the corresponding database API; acquiring a script corresponding to a database management task item according to the mapping relation; executing the script on the database to dynamically operate the database;
splitting the operation statement into a plurality of parameters and a database operation type according to the mapping relation; the step of splitting the operation statement into a plurality of parameters and a database operation type according to the mapping relation comprises the following substeps: splitting the character string to be analyzed according to the mapping relation, so as to obtain a database operation statement array; traversing the database operation statement array to split the operation statement into a plurality of parameters and database operation types; the step of traversing the array of database operation statements to split the operation statements into a plurality of parameters and database operation types includes the steps of: s321, detecting whether unprocessed operation statements exist or not, and if yes, taking down one operation statement, wherein the database operation statement array comprises a plurality of operation statements; s322, splitting the operation statement into a plurality of parameters and a database operation type, and returning to the step S321 until the operation statement is processed;
respectively inputting a plurality of values of the parameters, and calling a database API according to the values of the parameters and the operation type of the database; the step of inputting a plurality of values of the parameters respectively and calling the database API according to the values of the parameters and the database operation type further comprises: and calling a database API (application programming interface) to query the database, and storing a database return result into a variable.
2. A database management apparatus, comprising:
the definition unit is used for defining operation statements including addition, deletion, modification, search and storage in the database;
the mapping establishing unit is used for establishing the mapping relation between the defined operation statement and the corresponding database API; the mapping establishing unit includes: the mapping establishing module is used for establishing the mapping relation between the defined operation statement and the corresponding database API; the script obtaining module is used for obtaining a script corresponding to the database management task item according to the mapping relation; the script execution module is used for executing the script on the database so as to dynamically operate the database;
the splitting unit is used for splitting the operation statement into a plurality of parameters and database operation types according to the mapping relation; the splitting unit includes: the character string splitting module is used for splitting the character string to be analyzed according to the mapping relation so as to obtain a database operation statement array; the array traversing module is used for traversing the database operation statement array so as to divide the operation statement into a plurality of parameters and database operation types; the array traversal module comprises: the statement detection submodule is used for detecting whether unprocessed operation statements exist or not, and if the unprocessed operation statements exist, taking down one operation statement, wherein the database operation statement array comprises a plurality of operation statements; the splitting sub-module is used for splitting the operation statement into a plurality of parameters and a database operation type;
the calling unit is used for respectively inputting a plurality of values of the parameters and calling a database API according to the values of the parameters and the operation type of the database; the calling unit is further configured to: and calling a database API (application programming interface) to query the database, and storing a database return result into a variable.
CN201610560942.4A 2016-07-15 2016-07-15 Database management method and device Active CN107622070B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610560942.4A CN107622070B (en) 2016-07-15 2016-07-15 Database management method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610560942.4A CN107622070B (en) 2016-07-15 2016-07-15 Database management method and device

Publications (2)

Publication Number Publication Date
CN107622070A CN107622070A (en) 2018-01-23
CN107622070B true CN107622070B (en) 2021-05-14

Family

ID=61087046

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610560942.4A Active CN107622070B (en) 2016-07-15 2016-07-15 Database management method and device

Country Status (1)

Country Link
CN (1) CN107622070B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108920566B (en) * 2018-06-21 2020-10-20 吉林亿联银行股份有限公司 Method, device and equipment for operating SQLite database
CN109063070B (en) * 2018-07-23 2022-03-25 郑州云海信息技术有限公司 Database operation method and database server

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040220956A1 (en) * 2003-04-30 2004-11-04 Dillon Software Services, Llc Software framework that facilitates design and implementation of database applications
CN103699620A (en) * 2013-12-19 2014-04-02 珠海世纪鼎利通信科技股份有限公司 Method and system for achieving database operation by utilizing object relational mapping (ORM) frame in object orientation
CN104267932A (en) * 2014-08-12 2015-01-07 广州华多网络科技有限公司 Method, device and server for operating databases
CN105069142A (en) * 2015-08-18 2015-11-18 山大地纬软件股份有限公司 System and method for extraction, transformation and distribution of data increments
CN105117233A (en) * 2015-09-14 2015-12-02 百度在线网络技术(北京)有限公司 API calling method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040220956A1 (en) * 2003-04-30 2004-11-04 Dillon Software Services, Llc Software framework that facilitates design and implementation of database applications
CN103699620A (en) * 2013-12-19 2014-04-02 珠海世纪鼎利通信科技股份有限公司 Method and system for achieving database operation by utilizing object relational mapping (ORM) frame in object orientation
CN104267932A (en) * 2014-08-12 2015-01-07 广州华多网络科技有限公司 Method, device and server for operating databases
CN105069142A (en) * 2015-08-18 2015-11-18 山大地纬软件股份有限公司 System and method for extraction, transformation and distribution of data increments
CN105117233A (en) * 2015-09-14 2015-12-02 百度在线网络技术(北京)有限公司 API calling method and device

Also Published As

Publication number Publication date
CN107622070A (en) 2018-01-23

Similar Documents

Publication Publication Date Title
CN110908997B (en) Data blood relationship construction method and device, server and readable storage medium
US11157560B2 (en) System and method for managing graph data
CN109710220B (en) Relational database query method, relational database query device, relational database query equipment and storage medium
CN106407360B (en) Data processing method and device
US8667010B2 (en) Database table partitioning allowing overlaps used in full text query
CN112988782B (en) Hive-supported interactive query method and device and storage medium
CN113204571B (en) SQL execution method and device related to write-in operation and storage medium
CN109656950B (en) Recursive query method, device, server and storage medium
CN111259067A (en) Method, device and equipment for realizing DAO interface based on Spring
CN112506964A (en) Data query method, system and computer readable storage medium
CN107622070B (en) Database management method and device
WO2018001041A1 (en) Interface implementation method and device, set-top box, and storage medium
CN110704472A (en) Data query statistical method and device
CN111078728B (en) Cross-database query method and device in database archiving mode
CN112860265A (en) Method and device for detecting operation abnormity of source code database
CN115114325B (en) Data query method and device, electronic equipment and storage medium
CN110955712A (en) Development API processing method and device based on multiple data sources
CN111125090A (en) Data access method and device
CN112765180B (en) Method and device for analyzing column names of table building logs of DB2 database
CN110647535B (en) Method, terminal and storage medium for updating service data to Hive
CN112416966B (en) Impromptu query method, impromptu query device, computer device and storage medium
US6925630B1 (en) Method for generating code for processing a database
CN114547083A (en) Data processing method and device and electronic equipment
CN110263055B (en) Parameter prompting method, device, equipment and storage medium
CN111723104A (en) Method, device and system for syntax analysis in data processing system

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