Database management method, electronic device and computer readable storage medium

By receiving operation instructions of SQL identifiers and target object parameters, and using annotation information to automatically generate SQL files, it solves the problem in the existing technology that developers need to manually write SQL statements, and realizes the improvement of database management convenience and scalability.

CN111797073BActive Publication Date: 2024-10-18BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201911171422.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-11-26
Publication Date
2024-10-18
Estimated Expiration
2039-11-26

AI Technical Summary

Technical Problem

In existing database management methods, developers need to manually write SQL statements, which results in cumbersome operations and is not conducive to expanding applications.

Method used

By receiving operation instructions carrying SQL identifiers and target object parameters, it automatically generates SQL files using annotation information, determines the execution instructions corresponding to the SQL identifiers, and realizes read and write operations on the database, reducing the need to manually enter SQL statements.

Benefits of technology

It simplifies the database management process, improves convenience and scalability, reduces developers' operating steps, and improves database management efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111797073B_ABST
    Figure CN111797073B_ABST
Patent Text Reader

Abstract

The present invention provides a database management method, an electronic device and a computer-readable storage medium. In the method, an operation instruction for a database is received, the operation instruction carries a first SQL identifier of a structured query language SQL and parameter information of a target object, and then, in an SQL file corresponding to the target object, a second SQL identifier corresponding to the first SQL identifier is queried; wherein the SQL file is automatically generated using annotation information, and the annotation information is used to indicate the correspondence between an object and database table information, so that the database is processed according to the execution instruction corresponding to the second SQL identifier. The technical solution provided by the present invention can improve the convenience and expansion capability of the database management process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a database management method, electronic equipment and computer-readable storage medium. Background Art

[0002] The database is an important part of the computer system network. The logical code of the business system, user data and other data are all stored in the database.

[0003] The database implements external data interaction through the database interface. The database interface is generally an API interface written in JAVA language, which generally complies with a series of interface specifications defined by the JDBC framework. When managing the database in terms of data reading and data writing, the database interface needs to receive operation instructions for the database. The operation instructions need to carry the structured query language (SQL) corresponding to the operation. The database interface can implement the management of the database according to the SQL carried in the operation instructions. The SQL carried in the operation instructions is generally manually written and input by the developer. This processing method is very cumbersome, inconvenient to use, and not conducive to expanding applications. Summary of the invention

[0004] The present invention provides a database management method, electronic equipment and computer-readable storage medium, which are used to improve the convenience and expansion capability of the database management process.

[0005] In a first aspect, the present invention provides a database management method, comprising:

[0006] Receive an operation instruction for a database, wherein the operation instruction carries a first SQL identifier of a structured query language SQL and parameter information of a target object;

[0007] In the SQL file corresponding to the target object, a second SQL identifier corresponding to the first SQL identifier is searched; wherein the SQL file is automatically generated using annotation information, and the annotation information is used to indicate the corresponding relationship between the object and the database table information;

[0008] The database is processed according to the execution instruction corresponding to the second SQL identifier.

[0009] In a second aspect, the present invention provides an electronic device, comprising:

[0010] A receiving module, configured to receive an operation instruction for a database, wherein the operation instruction carries a first SQL identifier of a structured query language SQL and parameter information of a target object;

[0011] A query module, used to query a second SQL identifier corresponding to the first SQL identifier in a SQL file corresponding to the target object; wherein the SQL file is automatically generated using annotation information, and the annotation information is used to indicate a corresponding relationship between an object and database table information;

[0012] A processing module is used to process the database according to the execution instruction corresponding to the second SQL identifier.

[0013] In a third aspect, the present invention provides an electronic device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the database management method described in the first aspect are implemented.

[0014] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the method as described in the first aspect.

[0015] The present invention provides a database management method, an electronic device and a computer-readable storage medium. In this solution, the operation instruction only needs to carry the first SQL identifier and the parameter information of the target object, and the second SQL identifier corresponding to the first SQL identifier can be determined in the SQL file of the target object. In this way, the read and write operations for the database can be performed based on the second SQL identifier. In this process, the operation instruction does not need to carry a complete SQL statement, so the developer does not need to manually input the SQL statement, which simplifies the operation steps and is conducive to improving the convenience of the database management process, which also improves the expansion capability of the database to a certain extent. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0017] Figure 1 A schematic diagram of a scenario architecture of a database management method provided by an embodiment of the present invention;

[0018] Figure 2 A flowchart of a database management method provided by an embodiment of the present invention;

[0019] Figure 3 A schematic diagram of annotation information provided by an embodiment of the present invention;

[0020] Figure 4 A schematic diagram of a process for generating an SQL file provided by an embodiment of the present invention;

[0021] Figure 5A functional block diagram of an electronic device provided by an embodiment of the present invention;

[0022] Figure 6 A schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention.

[0023] The above drawings show clear embodiments of the present disclosure, which will be described in more detail below. These drawings and text descriptions are not intended to limit the scope of the present disclosure in any way, but to illustrate the concepts of the present disclosure to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0024] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0025] The technical solution provided in the embodiment of the present invention can be applied to any database or database interface. Figure 1 , Figure 1 FIG. 1 is a schematic diagram showing a database management scenario provided by an embodiment of the present invention. Figure 1 As shown, a database interface 111 is provided in the database 110, and the database 110 can exchange data with the business system 120 through the database interface 111. Therefore, the database management method provided in the embodiment of the present invention can be applied to the database interface 111. In another possible embodiment, the database management method can also be directly applied to the database 110. When any user needs to perform management operations such as reading and / or writing to the database, the database management method can be used to achieve it.

[0026] For example, when a user searches for a target product on a shopping website, the shopping system can call a database interface to query the information in the database.

[0027] For another example, when a user communicates with other users through a chat software, the chat software system needs to write the chat records into a database for the user to view later.

[0028] For another example, when a user operates on a browser to delete historical records, the browser client may also delete these historical records from the database at the same time.

[0029] It can be understood that in the above examples, the business systems corresponding to the database can be various, and the management methods for the database can be the same in different business systems. In addition, the embodiment of the present invention has no special limitation on the type of business system, which can be the client of each application (Application, APP) installed on the server or terminal device.

[0030] In addition, the database may be an electronic device dedicated to data storage, a data storage location in an electronic device, or a mobile storage device.

[0031] The business system and database can be independent electronic devices, such as a server and a database; or, the business system and the database can be located in the same electronic device, for example, the client (business system) of a shopping app and the storage location (database) of the shopping app in the mobile phone are located in the same mobile phone.

[0032] In the data management process involving reading and / or writing of a database, in the prior art, the database management is implemented by developers manually writing SQL statements, which is cumbersome to implement and not conducive to expansion.

[0033] The technical solution provided by the present invention is intended to solve the above technical problems of the prior art.

[0034] The following specific embodiments are used to describe in detail the technical solutions of the present invention and how the technical solutions of the present application solve the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present invention will be described below in conjunction with the accompanying drawings.

[0035] Embodiment 1

[0036] The embodiment of the present invention provides a database management method. For example, please refer to Figure 2 The database management method provided by the embodiment of the present invention may include the following steps:

[0037] S202: Receive an operation instruction for a database, where the operation instruction carries a first SQL identifier of a structured query language SQL and parameter information of a target object.

[0038] Specifically, when performing management operations on a database, there is no need to carry a complete SQL statement, only an SQL identifier for executing the instruction is required.

[0039] The data of the target object is stored in the database, and the target object can be any type of object. For example, the target object can be a product in a shopping app, a chat record in a chat app, or a historical browsing record.

[0040] S204, searching for a second SQL identifier corresponding to the first SQL identifier in the SQL file corresponding to the target object; wherein the SQL file is automatically generated using annotation information, and the annotation information is used to indicate the correspondence between the object and the database table information.

[0041] In the embodiment of the present invention, the SQL file of each object can be automatically generated according to the annotation information of each object, and multiple SQL identifiers can be included in the SQL file. In this way, when implementing this solution, it is only necessary to query the second SQL identifier corresponding to the first SQL identifier in the SQL file of the target object, and the management of the database can be realized according to the execution instruction corresponding to the second SQL identifier.

[0042] The database can store the data of each object in the form of a database table, and the object corresponds to the database table one by one. The database table can store various types of information of the object. The database table can have multiple columns, and each column can store different information. In a possible embodiment, each column of the database table can correspond to an object attribute.

[0043] In the embodiment of the present invention, the annotation information can be manually added by the developer, or when the object is stored in the database, an association relationship between the object and the database table information can be automatically established, and the annotation information can be added to the object.

[0044] S206: Process the database according to the execution instruction corresponding to the second SQL identifier.

[0045] The execution instructions designed in the embodiments of the present invention may include but are not limited to: at least one of the following: object insertion; physical deletion based on primary key; logical deletion based on primary key; physical deletion based on attribute; logical deletion based on attribute; modification based on attribute; querying object list based on attribute; counting the number of objects based on attribute.

[0046] In the SQL file, the SQL identifiers corresponding to the aforementioned execution instructions can be:

[0047] The SQL identifier corresponding to object insertion can be insertEntity;

[0048] The SQL identifier corresponding to physical deletion based on the primary key can be deleteEntityByPk;

[0049] The SQL identifier corresponding to the primary key logical deletion can be logicDeleteEntityByPk;

[0050] The SQL identifier corresponding to the physical deletion based on the attribute can be deleteEntityByAttr;

[0051] The SQL identifier corresponding to the attribute logical deletion can be logicDeleteEntityByAttr;

[0052] The SQL identifier corresponding to the attribute modification may be updateEntityByAttr;

[0053] The SQL identifier corresponding to the object list query based on the attribute may be selectEntityByAttr;

[0054] The SQL identifier corresponding to counting the number of objects according to attributes may be countEntityByAttr.

[0055] In summary, it is only necessary to manage the data stored in the database according to the aforementioned execution instruction corresponding to the second SQL identifier.

[0056] The above-mentioned technical solution provided by the embodiment of the present invention can automatically generate a corresponding SQL file according to the annotation information of the object, so that when managing the database, only the first SQL identifier and the parameter information of the target object need to be carried, and the second SQL identifier corresponding to the first SQL identifier can be determined in the SQL file of the target object, so that the read and write operations on the database can be performed based on the second SQL identifier. In this process, the operation instruction does not need to carry a complete SQL statement, so the developer does not need to manually enter the SQL statement, which simplifies the operation steps and is conducive to improving the convenience of the database management process, which also improves the expansion capability of the database to a certain extent.

[0057] The following, combined Figure 2 The illustrated embodiments further illustrate various implementations of the embodiments of the present invention.

[0058] In the embodiment of the present invention, the annotation information may include but is not limited to:

[0059] The first annotation information is used to indicate the mapping relationship between the object and the database table;

[0060] The second annotation information is used to indicate the mapping relationship between the attributes of the object and the column names of the database table.

[0061] For example, Figure 3A possible embodiment is shown. In this embodiment, the first annotation information is the DbTable annotation. DbTable is an annotation acting on the object class. The name attribute in the class is the name of the database table, which is used to indicate the mapping relationship between the object and the database table. The second annotation information is the DbColumn annotation. DbColumn is an annotation acting on the attribute of the object. The attribute of the object is the name of the column in the database table structure. In this way, DbColumn is used to indicate the mapping relationship between the object attribute and the database table column name.

[0062] In the embodiment of the present invention, the parameter information may include annotation information.

[0063] In addition, the parameter information may also include but is not limited to the properties of the objects involved in the above embodiments, wherein the properties of the objects may include but are not limited to: database primary key (id); data creator (creator); data editor (editor); data creation time (created); data modification time (modified); whether the data is valid (yn).

[0064] As mentioned above, in the embodiment of the present invention, the SQL file, which can also be called SQL MAP file, is automatically generated using annotation information. The generation method of the SQL file is now described.

[0065] For example, please refer to Figure 4 The database management method provided in the embodiment of the present invention may further include the following steps:

[0066] S402, receiving a generation request for generating the SQL file, wherein the generation request carries the identifier of the target object, the template type and the storage location information.

[0067] In such Figure 4 In the illustrated embodiment, there may be multiple template types. For example, the template type of the SQL file may include but is not limited to: an IBATIS framework type template (used to generate an SQL MAP file of an IBATIS framework) or a MYBATIS framework type template (used to generate an SQL MAP file of a MYBATIS framework).

[0068] It should be noted that a template of any template type contains at least one SQL identifier, and each SQL identifier corresponds to an execution instruction for the database; and the SQL identifiers contained in any two templates are different.

[0069] S404: Acquire database table information of the target object using the annotation information and attributes.

[0070] As mentioned above, the first annotation information may be used to first obtain the database table corresponding to the target object in the database; and then, the second annotation information may be used to obtain the database column name information corresponding to each of the attributes in the database table.

[0071] S406: Fill the database table information into the target template indicated by the template type to obtain the SQL file.

[0072] In the embodiment of the present invention, the SQL file can be written using Velocity. Specifically, the specific information in the database table column can be read according to the aforementioned first annotation information and the second annotation information, and then, based on the target template, the template synthesis method in the Velocity application programming interface (API) is called to write the specific information in the database table column into the target template to obtain the SQL file.

[0073] S408: Store the SQL file according to the storage location information.

[0074] The storage location information may be a storage path or a name of a storage location. Thus, if the storage location information is a storage path, the target storage location is determined according to the storage path, and the SQL file is stored in the target storage location. If the storage location information is a name of a storage location, the SQL file is stored in the storage location corresponding to the name.

[0075] Based on Figure 4 The method provided in the illustrated embodiment can automatically generate SQL files for each object and implement automatic storage, eliminating the need for developers to manually write SQL statements for each object, thus simplifying the developer's processing steps and helping to improve database management efficiency.

[0076] It should be noted that Figure 4 The embodiment shown is for illustration only. In actual implementation scenarios, the embodiment of the present invention has no particular limitation on the template type and / or storage location information. That is, the generation request may carry the identifier of the target object, and may also carry at least one of the template type and storage location information.

[0077] In a specific embodiment, a fixed type of SQL file may be generated. In this case, the generation request may only carry the identifier of the target object, or carry the identifier of the target object and storage location information without carrying the template type.

[0078] Alternatively, in another embodiment, the embodiment of the present invention may also generate multiple different types of SQL files. For example, the template type of the SQL file may include but is not limited to: an IBATIS framework type template (used to generate an SQLMAP file of an IBATIS framework) or a MYBATIS framework type template (used to generate an SQL MAP file of a MYBATIS framework). In this case, the generation request needs to carry template type information. That is, the generation request may only carry the identifier and template type of the target object; or, carry the identifier, template type and storage location information of the target object.

[0079] Similarly, in another specific embodiment, the generated SQL file can be stored in a fixed default storage location, which can be preset by the developer or manually changed by the user. In this case, the generation request does not need to carry the storage location information. For example, the generation request can only carry the identifier of the target object, or the generation request can carry the identifier of the target object and the template type.

[0080] Alternatively, in another embodiment, the user may directly specify the storage location in the generation request, that is, the generation request may carry the storage location information. For example, the generation request may only carry the identifier of the target object and the storage location information, or the generation request may carry the identifier of the target object, the template type, and the storage location information.

[0081] Then, based on the generated SQL file, when executing a specific database management operation, it is necessary to determine the second SQL identifier corresponding to the first SQL identifier in the SQL file.

[0082] In an embodiment of the present invention, the second SQL identifier may be associated with the identifier of the target object and the identifier of the execution instruction. Specifically, the second SQL identifier may be composed of the identifier (ID) of the target object and the identifier of the execution instruction.

[0083] Exemplarily, the structure of the second SQL identifier may be: object class name + period + identifier of the execution instruction. If the object class name is in uppercase letters, it may be converted to lowercase letters. For example, if the object class name is User and the identifier of the execution instruction is insertEntity, the generated second SQL identifier may be user.insertEntity.

[0084] Based on this, in the SQL file, when querying the second SQL identifier corresponding to the first SQL identifier, it is only necessary to determine the execution instruction to be executed according to the first SQL identifier, and then determine the second SQL identifier according to the identifier of the execution instruction.

[0085] For example, if the first SQL identifier is an operation of inserting an object, it can correspond to an execution instruction related to insert, and then to the second SQL identifier of insertEntity. For another example, if the first SQL identifier is an update operation, it can correspond to an execution instruction related to update, and then to the second SQL identifier of updateEntityByAttr. For another example, if the first SQL identifier is a query operation, it can correspond to an execution instruction related to select, and then to the second SQL identifier of selectEntityByAttr. For another example, if the first SQL identifier is a delete operation, it can correspond to an execution instruction related to delete, and then to multiple second SQL identifiers related to delete, and then determine the final second SQL identifier based on the parameter information of the target object.

[0086] Based on the above embodiments, the management operation for the database mainly involves two aspects: reading data and writing data. Based on this, in order to further improve the efficiency of database management, the read-write separation technology can also be used to achieve the management of the database. That is, the database has a read interface and a write interface, so that the relevant functions of reading data can be implemented through the read interface, and the relevant functions of writing data can be implemented through the write interface, so as to achieve read-write separation.

[0087] In a possible embodiment, the reading interface may be a ReadDao interface, and the writing interface may be a WriteDao interface, and JAVA generics are used in the interface method definition. In the built-in method of the database interface, three parameters may be included: object class information, object, and SQL identifier. Among them, the object class information means that the class of the object is a subclass of the abstract domain object base class BaseModel, and the SQL identifier here is not the aforementioned second SQL identifier, but the first SQL identifier. The second SQL identifier is finally determined by the aforementioned method, and the corresponding instruction is executed according to the second SQL identifier.

[0088] So, in execution Figure 2 The step S206 shown can be implemented as follows:

[0089] Calling a read interface or a write interface according to the execution instruction corresponding to the second SQL identifier;

[0090] The database is processed using the read interface or the write interface.

[0091] That is, the read interface is used to implement execution instructions related to reading the database, such as querying the data in the database; the write interface is used to implement processing related to writing to the database, such as writing data to the database, and for example, updating the data in the database.

[0092] The embodiment of the present invention uses the annotation information of the object to realize the mapping relationship between the object and the database table name, and the mapping relationship between the object attribute and the column name of the database table. Moreover, based on the annotation information, the SQL MAP file of the object can also be automatically generated according to the template based on the common basic attributes of the object, so that the one-to-one correspondence of the SQL identifier (ID) can be realized based on the SQL file. As for the database interface, generics are used in the API of the interface to solve the read-write separation of different entities, and users can also customize SQL identifiers to realize the functional expansion of database management.

[0093] It is to be understood that some or all of the steps or operations in the above embodiments are merely examples, and the present application embodiments may also perform other operations or variations of various operations. In addition, the various steps may be performed in different orders presented in the above embodiments, and it is possible that not all of the operations in the above embodiments need to be performed.

[0094] The words used in this application are only used to describe the embodiments and are not used to limit the claims. As used in the description of the embodiments and claims, unless the context clearly indicates, the singular forms of "a", "an" and "the" are intended to include the plural forms as well. Similarly, the term "and / or" as used in this application refers to any and all possible combinations of one or more associated listings. In addition, when used in this application, the term "comprise" and its variants "comprises" and / or including (comprising) refer to the existence of stated features, wholes, steps, operations, elements, and / or components, but do not exclude the existence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups of these.

[0095] Embodiment 2

[0096] Based on the database management method provided in the first embodiment above, the present invention further provides a device embodiment for implementing each step and method in the above method embodiment.

[0097] An embodiment of the present invention provides an electronic device, please refer to Figure 5 , the electronic device 500 comprises:

[0098] A receiving module 52, configured to receive an operation instruction for a database, wherein the operation instruction carries a first SQL identifier of a structured query language SQL and parameter information of a target object;

[0099] A query module 54, configured to query a second SQL identifier corresponding to the first SQL identifier in a SQL file corresponding to the target object; wherein the SQL file is automatically generated using annotation information, and the annotation information is used to indicate a corresponding relationship between an object and database table information;

[0100] The processing module 56 is used to process the database according to the execution instruction corresponding to the second SQL identifier.

[0101] In a specific embodiment, the annotation information includes:

[0102] The first annotation information is used to indicate the mapping relationship between the object and the database table;

[0103] The second annotation information is used to indicate the mapping relationship between the attributes of the object and the column names of the database table.

[0104] In another embodiment, the parameter information further includes attributes;

[0105] The attributes include: database primary key; data creator; data modifier; data creation time; data modification time; whether the data is valid.

[0106] In another embodiment, the receiving module 52 is further used to receive a generation request for generating the SQL file, wherein the generation request carries the identifier of the target object, the template type and the storage location information;

[0107] The processing module 56 is further configured to:

[0108] Using the annotation information and attributes, obtaining database table information of the target object;

[0109] Fill the database table information into the target template indicated by the template type to obtain the SQL file;

[0110] The SQL file is stored according to the storage location information.

[0111] In another embodiment, the processing module 56 is further specifically configured to:

[0112] Using the first annotation information, obtaining a database table corresponding to the target object in the database;

[0113] The second annotation information is used to obtain database column name information corresponding to each of the attributes in the database table.

[0114] In another embodiment, the target template includes: an IBATIS framework type template or a MYBATIS framework type template.

[0115] In another embodiment, a template of any template type includes at least one SQL identifier, and each SQL identifier corresponds to an execution instruction for the database;

[0116] The SQL identifiers contained in any two of the templates are different.

[0117] In another embodiment, the execution instruction includes at least one of the following: object insertion; physical deletion based on primary key; logical deletion based on primary key; physical deletion based on attribute; logical deletion based on attribute; modification based on attribute; querying object list based on attribute; counting object quantity based on attribute.

[0118] In another embodiment, the second SQL identifier is associated with an identifier of the target object and an identifier of the execution instruction.

[0119] In another embodiment, the processing module 56 is further specifically configured to:

[0120] Calling a read interface or a write interface according to the execution instruction corresponding to the second SQL identifier;

[0121] The database is processed using the read interface or the write interface.

[0122] Figure 5 The electronic device 500 of the illustrated embodiment can be used to execute the technical solution of the above-mentioned method embodiment. Its implementation principle and technical effects can be further referred to the relevant description in the method embodiment. Optionally, the electronic device 500 can be a server or a terminal.

[0123] It should be understood that the above Figure 5The division of the modules of the electronic device 500 shown is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software calling through processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software calling through processing elements, and some modules can be implemented in the form of hardware. For example, the processing module 54 can be a separately established processing element, or it can be integrated in the electronic device 500, such as a chip of the terminal. In addition, it can also be stored in the memory of the electronic device 500 in the form of a program, and called and executed by a processing element of the electronic device 500. The implementation of other modules is similar. In addition, these modules can be fully or partially integrated together, or they can be implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.

[0124] For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASIC), or one or more digital singnal processors (DSP), or one or more field programmable gate arrays (FPGA). For another example, when a certain module above is implemented in the form of a processing element scheduler, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call a program. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).

[0125] Furthermore, an embodiment of the present invention provides an electronic device, please refer to Figure 6 The electronic device 500 includes: a memory 510, a processor 520, and a computer program stored in the memory 510 and executable on the processor 520. When the processor 520 executes the program, the method of the above embodiment can be implemented.

[0126] The number of processors 520 in the electronic device 500 may be one or more, and the processor 520 may also be referred to as a processing unit, which may implement certain control functions. The processor 520 may be a general-purpose processor or a dedicated processor, etc. In an optional design, the processor 520 may also store instructions, which may be executed by the processor 520, so that the electronic device 500 executes the method described in the above method embodiment.

[0127] In yet another possible design, the electronic device 500 may include a circuit, and the circuit may implement the functions of sending, receiving, or communicating in the aforementioned method embodiments.

[0128] Optionally, the number of memories 510 in the electronic device 500 may be one or more, and the memory 510 may store instructions or intermediate data, and the instructions may be executed on the processor 520, so that the electronic device 500 performs the method described in the above method embodiment. Optionally, other relevant data may also be stored in the memory 510. Optionally, instructions and / or data may also be stored in the processor 520. The processor 520 and the memory 510 may be provided separately or integrated together.

[0129] In addition, if Figure 6 As shown, a transceiver 530 is also provided in the electronic device 500, wherein the transceiver 530 can be called a transceiver unit, a transceiver, a transceiver circuit, or a transceiver, etc., and is used for data transmission or communication with a test device or other terminal devices, which will not be repeated here.

[0130] like Figure 6 As shown, the memory 510, the processor 520 and the transceiver 530 are connected and communicated via a bus.

[0131] In addition, an embodiment of the present invention provides a readable storage medium on which a computer program is stored. The computer program is executed by a processor to implement the method described in the first embodiment.

[0132] Since each module in this embodiment can execute the method shown in the first embodiment, for the parts not described in detail in this embodiment, reference may be made to the relevant description of the first embodiment.

[0133] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be regarded as exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0134] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A database management method, characterized in that: Applied to a database interface, the method comprises: Receive an operation instruction for a database, wherein the operation instruction carries a first SQL identifier of a structured query language SQL and parameter information of a target object; In the SQL file corresponding to the target object, a second SQL identifier corresponding to the first SQL identifier is searched; wherein the SQL file is automatically generated using annotation information, and the annotation information is used to indicate the corresponding relationship between the object and the database table information; Processing the database according to the execution instruction corresponding to the second SQL identifier; The method further comprises: Receive a request for generating the SQL file, wherein the request carries the identifier, template type, and storage location information of the target object; Using the annotation information and attributes, obtaining database table information of the target object; Fill the database table information into the target template indicated by the template type to obtain the SQL file; The SQL file is stored according to the storage location information.

2. The method according to claim 1, characterized in that The annotation information includes: The first annotation information is used to indicate the mapping relationship between the object and the database table; The second annotation information is used to indicate the mapping relationship between the attributes of the object and the column names of the database table.

3. The method according to claim 1, characterized in that: The parameter information also includes attributes; The attributes include: database primary key; data creator; data modifier; data creation time; data modification time; whether the data is valid.

4. The method according to claim 1, characterized in that: The step of obtaining the database table information of the target object by using the annotation information and attributes includes: Using the first annotation information, obtaining a database table corresponding to the target object in the database; The second annotation information is used to obtain database column name information corresponding to each of the attributes in the database table.

5. The method according to claim 1, characterized in that The target template includes: an IBATIS framework type template or a MYBATIS framework type template.

6. The method according to any one of claims 1 to 3, characterized in that: A template of any template type contains at least one SQL identifier, and each SQL identifier corresponds to an execution instruction for the database; The SQL identifiers contained in any two of the templates are different.

7. The method according to any one of claims 1 to 3, characterized in that: The execution instructions include at least one of the following: object insertion; physical deletion based on primary key; logical deletion based on primary key; physical deletion based on attribute; logical deletion based on attribute; modification based on attribute; querying object list based on attribute; counting object quantity based on attribute.

8. The method according to any one of claims 1 to 3, characterized in that: The second SQL identifier is associated with the identifier of the target object and the identifier of the execution instruction.

9. The method according to any one of claims 1 to 3, characterized in that: The processing of the database according to the execution instruction corresponding to the second SQL identifier includes: Calling a read interface or a write interface according to the execution instruction corresponding to the second SQL identifier; The database is processed using the read interface or the write interface.

10. An electronic device, characterized in that: include: A receiving module, configured to receive an operation instruction for a database, wherein the operation instruction carries a first SQL identifier of a structured query language SQL and parameter information of a target object; A query module, used to query a second SQL identifier corresponding to the first SQL identifier in a SQL file corresponding to the target object; wherein the SQL file is automatically generated using annotation information, and the annotation information is used to indicate a corresponding relationship between an object and database table information; A processing module, configured to process the database according to the execution instruction corresponding to the second SQL identifier; The receiving module is further used to receive a generation request for generating the SQL file, wherein the generation request carries the identifier of the target object, the template type and the storage location information; Using the annotation information and attributes, obtaining database table information of the target object; Fill the database table information into the target template indicated by the template type to obtain the SQL file; The SQL file is stored according to the storage location information.

11. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method according to any one of claims 1 to 9 when executing the program.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.

Citation Information

Patent Citations

  • Object query method and device, computer device and storage medium

    CN109669951A

  • Database operation processing method and device, computer equipment and storage medium

    CN110309123A