Adaptation Method, Device, Storage Medium and Computer Device for DM Database

By loading the Dameng database operation code package in the ORM framework, the problem that the Dameng database does not support the node.js ORM framework is solved, and the unified operation of the SQL database and the Dameng database is realized, reducing the development and maintenance costs.

CN114969179BActive Publication Date: 2025-07-25YGSOFT INC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210441507.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-25
Publication Date
2025-07-25
Estimated Expiration
2042-04-25

AI Technical Summary

Technical Problem

Dameng database does not support node.js-related ORM frameworks, which leads to the need to write separate code when managing Dameng database using node.js, which increases the workload of development and maintenance.

Method used

By loading the Dameng database operation code package in the ORM framework, creating a database connection pool, and converting the data type and request statement format to the format supported by the Dameng database, the adaptation of the Dameng database is achieved.

Benefits of technology

Reduces the cost of development and maintenance, and only one set of code is required to support the operation of the SQL database and the Dameng database.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114969179B_ABST
    Figure CN114969179B_ABST
Patent Text Reader

Abstract

The embodiments of the present application disclose an adaptation method, device, storage medium and computer device for DM databases, relating to the field of database management. The ORM framework of the present application has the ability to support node.js. Since the ORM framework itself supports the operation of SQL databases, by loading the operation code package of the DM database in the ORM framework in the present application, no separate coding is required. Therefore, developers only need one set of code to support the operation of SQL databases and DM databases, reducing development costs and maintenance time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of database management, and particularly to an adaptation method, device, storage medium, and computer device for DM database. Background Art

[0002] The DM (Data Management) database management system is a high-performance database management system launched by DM Company. It has the characteristics of generality, high performance, high availability, cross-platform, and high usability, so its application scope is becoming wider and wider. Since the DM database does not support the ORM (Object Relational Mapping) framework related to node.js, node.js supports the management of the mysql database but does not support the DM database. When using node.js to manage the DM database, it is necessary to write code separately, which results in a large workload and complex maintenance. Summary of the Invention

[0003] Embodiments of this application provide an adaptation method, device, storage medium, and computer device for the DM database. The technical solutions are as follows:

[0004] In a first aspect, embodiments of this application provide an adaptation method for the DM database. The method includes:

[0005] Invoking the DM database operation code package in the ORM framework to create a database connection pool for the DM database;

[0006] Connecting to the DM database through the database connection pool;

[0007] Converting the first data type from the ORM framework to the second data type supported by the DM database, creating a data type table supported by the DM database, and converting the format of the request statement from the ORM framework to the format supported by the DM database, and converting the format of the return result from the DM database to the format supported by the ORM framework.

[0008] In a second aspect, embodiments of this application provide an adaptation device for the DM database. The device includes:

[0009] A creation unit for invoking the DM database operation code package in the ORM framework to create a database connection pool for the DM database;

[0010] A connection unit for connecting to the DM database through the database connection pool;

[0011] A conversion unit is configured to convert a first data type from the ORM framework into a second data type supported by the DM database, create a data type table supported by the DM database, and convert the format of a request statement from the ORM framework into a format supported by the DM database, and convert the format of a return result from the DM database into a format supported by the ORM framework.

[0012] In a third aspect, an embodiment of the present application provides a computer storage medium storing multiple instructions, which are adapted to be loaded and executed by a processor to perform the above method steps.

[0013] In a fourth aspect, an embodiment of the present application provides a computer device, which may include: a processor and a memory; wherein, the memory stores a computer program, and the computer program is adapted to be loaded and executed by the processor to perform the above method steps.

[0014] The beneficial effects brought by the technical solutions provided in some embodiments of the present application at least include:

[0015] The ORM framework has the ability to support node.js. Since the ORM framework itself supports the operation of SQL databases, in this application, by loading a DM database operation code package in the ORM framework, no separate coding is required. Therefore, developers only need one set of code to support the operations of SQL databases and DM databases, reducing development costs and maintenance time. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0017] Figure 1 is a schematic diagram of a network architecture provided by an embodiment of the present application;

[0018] Figure 2 is a schematic flowchart of an adaptation method for a DM database provided by an embodiment of the present application;

[0019] Figure 3 is a schematic structural diagram of an adaptation device for a DM database provided by the present application;

[0020] Figure 4 is a schematic structural diagram of a computer device provided by the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0021] To make the objectives, technical solutions, and advantages of this application clearer, the following will further describe in detail the embodiments of this application in conjunction with the accompanying drawings.

[0022] It should be noted that the adaptation method for the DM database provided in this application is generally executed by a computer device. Correspondingly, the adaptation device for the DM database is generally set in the computer device.

[0023] Figure 1 An exemplary system architecture to which the adaptation method for the DM database or the adaptation device for the DM database of this application can be applied is shown.

[0024] As Figure 1 shown, the system architecture may include: a computer device 101 and a server 102. The computer device 101 and the server 102 can communicate with each other through a network. The network is a medium for providing a communication link between the above-mentioned various units. The network can include various types of wired communication links or wireless communication links. For example, the wired communication links include optical fibers, twisted pairs, or coaxial cables, etc., and the wireless communication links include Bluetooth communication links, Wireless-Fidelity (Wi-Fi) communication links, or microwave communication links, etc.

[0025] Among them, an ORM framework is installed in the computer device, and a DM database is deployed in the server 102. The computer device uses the ORM framework to access the DM database.

[0026] It should be noted that the computer device 101 and the server 102 can be hardware or software. When the computer device 101 and the server 102 are hardware, they can be implemented as a distributed server cluster composed of multiple servers, or as a single server. When the computer device 101 and the server 102 are software, they can be implemented as multiple software or software modules (for example, used to provide distributed services), or as a single software or software module. Specific limitations are not made here.

[0027] Various communication client applications can be installed on the computer device of this application. For example: video recording applications, video playback applications, voice interaction applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0028] The computer device can be hardware or software. When the computer device is hardware, it can be various computer devices with a display screen, including but not limited to smartphones, tablets, laptop portable computers, and desktop computers, etc. When the computer device is software, it can be installed in the above-listed computer devices. It can be implemented as multiple software or software modules (for example: used to provide distributed services), or as a single software or software module. Specific limitations are not made here.

[0029] When the computer device is hardware, a display device and a camera may also be installed thereon. The display device can be various devices capable of implementing a display function, and the camera is used to collect video streams. For example, the display device can be a cathode ray tube display (CR for short), a light-emitting diode display (LED for short), an electronic ink screen, a liquid crystal display (LCD for short), a plasma display panel (PDP for short), etc. Users can use the display device on the computer device to view information such as text, pictures, and videos displayed.

[0030] It should be understood that Figure 1 the numbers of computer devices, networks, and servers in

[0031] are only illustrative. According to the implementation requirements, there can be any number of computer devices, networks, and servers. Figure 2 Next, in combination with the attached Figure 1 drawings, a detailed introduction will be given to the adaptation method of the DM database provided in the embodiments of the present application. Among them, the adaptation device of the DM database in the embodiments of the present application can be

[0032] the computer device shown in Figure 2 . Figure 2 Please refer to

[0033] S201. Call the DM database operation code package in the ORM framework to create a database connection pool for the DM database.

[0034] Among them, the ORM framework of the present application includes but is not limited to ORM2, bookshelf, and sequelize components. The database connection pool is used to establish a connection with the DM database. Here, taking the sequelize component as an example of the ORM framework, the process of creating a database connection pool will be described. The methods for creating a database connection pool using other ORM frameworks can refer to the description of the sequelize component.

[0035] The code of the Sequelize component is added with a DM database operation code package. After the DM database is started, by calling the DM database operation code package, the DM database operation code package is used to create a database connection pool to connect to the DM database, adapt to the syntax of the DM database, operate on the DM database, and process the return results of the DM database. Optionally, the DM database operation code package dmdb can be set in the \lib\dialects\ directory of the Sequelize component. The DM database operation code package can be obtained by transforming the code package in the \lib\dialects\mysql directory of the Sequelize component. The following files are included in this directory: connection-manager.js, query.js, query-generator.js.

[0036] Furthermore, the method for creating a database connection pool may include: adding a DM database entry category in the unified entry Sequelize class of the Sequelize component. After obtaining the connection information identifier of the DM database (used to uniquely represent its identity), select the connection entry of the DM database and load the DM database operation library, that is, load the dmdb file in the dialects directory. The computer device enters the DM driver class based on the account, password, and service address of the DM database, and calls the createTableQuery method in this class to execute the operation of creating an instance. This method will use the createPoo in the DM database driver to connect to the database to create a database connection pool and return a database connection instance.

[0037] S202. Connect to the DM database through the database connection pool.

[0038] Among them, multiple database connections are set in the database connection pool. The computer device can monitor the load status of each database connection. The load status can be represented by throughput, the number of IO operations, etc., and connect the database connection with the lightest load to the DM database.

[0039] S203. Convert the first data type from the ORM framework to the second data type supported by the DM database, create a data type table supported by the DM database, and convert the format of the request statement from the ORM framework to the format supported by the DM database, and convert the format of the return result from the DM database to the format supported by the ORM framework.

[0040] Among them, the ORM framework has the functions of data type conversion, request statement format conversion, and return result conversion. The following takes the Sequelize component as the ORM framework for the conversion process as an example. The method for creating a database connection pool for other ORM frameworks can refer to the description of the Sequelize component.

[0041] In the code database operation code package, data types required by the DM database and the corresponding adaptation statements are added. Specifically, in the data-types.js file under the sequelize directory, the data types required by the DM database and the adaptation statements are added. The adaptation statements convert the first data type into the second data type supported by the DM database. For example, the first data types include VARCHAR2, NUMBER, DOUBLE, CLOB, BOOLEAN, BLOB, etc. For each data type, a key method and a tosql method are created to convert the data type into the second data type supported by the DM database. The mapping relationship between the first data type and the second data type in the sequelize component is as follows:

[0042] The first data type is INTEGER, and the second data type is DMDB_NUMBER; or

[0043] The first data type is DOUBLE, and the second data type is DMDB_DOUBLE; or

[0044] The first data type is TEXT, and the second data type is DMDB_CLOB; or

[0045] The first data type is BOOLEAN, and the second data type is DMDB_BOOLEAN; or

[0046] The first data type is BLOB, and the second data type is DMDB_BLOB.

[0047] Record this mapping relationship into the sequelize model library for subsequent data type conversion.

[0048] Furthermore, the computer device realizes the synchronization of database tables, creates a data type table corresponding to the DM database, and registers it in the model library through the model registration method import of the Sequelize component. The sync method is used to synchronize the data table, and the import method obtains the data types and adaptation statements set in data-types.js. According to the created SQL statement template, the corresponding table creation SQL statement is concatenated by the table name, fields, and types. For example: CREATE TABLE "user" (ID number(36) NOT NULL, MY_NAME varchar2(64) DEFAULT NULL). After generating the SQL statement, the query method is used to execute the SQL statement. After the query method obtains the SQL statement, it will keep executing and finally call the run method. The run method will operate the database by calling the connection instance object generated at the beginning, and finally achieve the purpose of creating a data table.

[0049] Furthermore, the request statements from the Sequelize component need to be converted into a format supported by the DM database. The computer device exposes a unified interface through the Sequelize component, such as: findALL, bulkCreat, create, destroy, execute, etc. The DMDBQueryGenerator statement generation class is created, which inherits from the AbstractQueryGenerator. The DM database operation statement templates for each interface are built into this class, and SQL statements are generated according to different parameters passed in (through string concatenation methods). After generation, the connection instance object is uniformly used to operate the database to implement the operations of adding, deleting, querying, and modifying the DM database for the Sequelize component interface.

[0050] Furthermore, the return results from the DM database need to be converted into a format supported by the Sequelize component to ensure the data unity of the return interface. The specific method is as follows: Operate the DM database in the run method of the final execution statement. Here, a promise object of the operation result of the DM database will be returned. The formatResult method is called in the last then of the promise object to obtain the processed return value. The return value is converted to obtain the final result, and the conversion is performed through the mapping relationship defined in data-types.js.

[0051] In the embodiments of the present application, the ORM framework has the ability to support node.js. Since the ORM framework itself supports the operation of SQL databases, the present application loads the DM database operation code package in the ORM framework without the need for separate coding. Therefore, developers only need a set of codes to support the operations of SQL databases and DM databases, reducing development costs and maintenance time.

[0052] The following are the device embodiments of the present application, which can be used to execute the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.

[0053] Please refer to Figure 3 , which shows a schematic structural diagram of an adaptation device for a DM database provided by an exemplary embodiment of the present application, hereinafter referred to as device 3. This device 3 can be implemented as all or part of a computer device through software, hardware, or a combination of both. Device 3 includes: a creation unit 301, a connection unit 302, and a conversion unit 303.

[0054] The creation unit 301 is used to call the DM database operation code package in the ORM framework to create a database connection pool for the DM database;

[0055] The connection unit 302 is used to connect to the DM database through the database connection pool;

[0056] The conversion unit 303 is used to convert the first data type from the ORM framework into the second data type supported by the DM database, create a data type table supported by the DM database, and convert the format of the request statement from the ORM framework into the format supported by the DM database, and convert the format of the return result from the DM database into the format supported by the Sequelize component.

[0057] In one or more possible embodiments, before calling the DM database operation code package in the ORM framework to create a database connection pool for the DM database, it further includes:

[0058] Generating a DM database operation code package according to the code package in the \lib\dialects\mysql directory of the Sequelize component;

[0059] Placing the DM database operation code package in the \lib\dialects\ directory of the Sequelize component.

[0060] In one or more possible embodiments,

[0061] The first data type is INTEGER and the second data type is DMDB_NUMBER; or

[0062] The first data type is DOUBLE and the second data type is DMDB_DOUBLE; or

[0063] The first data type is TEXT and the second data type is DMDB_CLOB; or

[0064] The first data type is BOOLEAN and the second data type is DMDB_BOOLEAN; or

[0065] The first data type is BLOB and the second data type is DMDB_BLOB.

[0066] In one or more possible embodiments, creating a database connection pool for the DM database by invoking the DM database operation code package in the ORM framework includes:

[0067] Loading the DM database operation code package;

[0068] Entering the driver class of the DM database according to the account information and service address;

[0069] Invoking the creatTableQurey method in the driver class to create a database connection pool.

[0070] In one or more possible embodiments, connecting to the DM database through the database connection pool includes:

[0071] Monitoring the load status of each database connection in the database connection pool;

[0072] Allocating the database connection with the lightest load status to the ORM framework so that the ORM framework accesses the DM database through the database connection.

[0073] In one or more possible embodiments, the request statement is used to perform an addition operation, a deletion operation, a search operation, or a modification operation on the DM database.

[0074] In one or more possible embodiments, converting the format of the return statement from the DM database to the format supported by the sequelize component includes:

[0075] Obtaining the operation result promise object from the DM database;

[0076] Determining the return value in the last then field in the promise object;

[0077] Convert the format of the return value into a format supported by the Sequelize component.

[0078] It should be noted that when the device 3 provided in the above embodiment executes the adaptation method for the DM database, only the division of the above functional modules is used for illustration. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the above functions. In addition, the adaptation device for the DM database provided in the above embodiment and the embodiment of the adaptation method for the DM database belong to the same concept. The implementation process is detailed in the method embodiment and will not be repeated here.

[0079] The serial numbers of the embodiments of the present application are only for description and do not represent the advantages or disadvantages of the embodiments.

[0080] The embodiment of the present application also provides a computer storage medium. The computer storage medium can store multiple instructions, and the instructions are suitable for being loaded and executed by a processor to perform the method steps of the above Figure 2 as shown in the embodiment. The specific execution process can be referred to Figure 2 the specific description of the shown embodiment and will not be elaborated here.

[0081] The present application also provides a computer program product. The computer program product stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the adaptation method for the DM database as described in each of the above embodiments.

[0082] Please refer to Figure 4 which is a schematic structural diagram of a computer device provided by an embodiment of the present application. As Figure 4 shown, the computer device 400 may include: at least one processor 401, at least one network interface 404, a user interface 403, a memory 405, and at least one communication bus 402.

[0083] Among them, the communication bus 402 is used to realize the connection and communication between these components.

[0084] Among them, the user interface 403 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 403 may further include a standard wired interface and a wireless interface.

[0085] Among them, the network interface 404 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface).

[0086] Among them, the processor 401 may include one or more processing cores. The processor 401 connects various parts within the entire computer device 400 through various interfaces and lines. By running or executing instructions, programs, code sets, or instruction sets stored in the memory 405, and by invoking data stored in the memory 405, it performs various functions of the computer device 400 and processes data. Optionally, the processor 401 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), or programmable logic array (PLA). The processor 401 may integrate a combination of one or more of a central processing unit (CPU), a graphics processing unit (GPU), and a modem, etc. Among them, the CPU mainly processes the operating system, user interface, application programs, etc.; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communication. It can be understood that the above-mentioned modem may not be integrated into the processor 401 and may be implemented separately by a single chip.

[0087] Among them, the memory 405 may include random access memory (RAM) and may also include read-only memory. Optionally, the memory 405 includes a non-transitory computer-readable storage medium. The memory 405 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 405 may include a program storage area and a data storage area. Among them, the program storage area may store instructions for implementing the operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store the data involved in the above-mentioned various method embodiments. Optionally, the memory 405 may also be at least one storage device located far from the aforementioned processor 401. As Figure 4 shown, the memory 405, as a computer storage medium, may include an operating system, a network communication module, a user interface module, and application programs.

[0088] In Figure 4In the computer device 400 shown, the user interface 403 is mainly used to provide an interface for the user to input and obtain the data input by the user; while the processor 401 can be used to call the application programs stored in the memory 405 and specifically execute as Figure 2 the method shown, and the specific process can be referred to Figure 2 shown, which will not be elaborated here.

[0089] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above various methods. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only memory, or a random access memory, etc.

[0090] The above-disclosed are only the preferred embodiments of the present application. Of course, the scope of the rights of the present application cannot be limited thereby. Therefore, equivalent changes made according to the claims of the present application still fall within the scope covered by the present application.

Claims

1. An adaptation method for DM database, characterized in that, Including: Generating a DM database operation code package based on the code package in the \lib\dialects\mysql directory of the Sequelize component; Placing the DM database operation code package in the \lib\dialects\ directory of the Sequelize component; Loading the DM database operation code package; Entering the driver class of the DM database according to the account information and service address; Invoking the creatTableQurey method in the driver class to create a database connection pool; Connecting to the DM database through the database connection pool; Converting the first data type from the ORM framework to the second data type supported by the DM database, creating a data type table supported by the DM database, and converting the format of the request statement from the ORM framework to the format supported by the DM database, and converting the format of the return result from the DM database to the format supported by the ORM framework.

2. The method according to claim 1, wherein The first data type is INTEGER and the second data type is DMDB_NUMBER; or The first data type is DOUBLE and the second data type is DMDB_DOUBLE; or The first data type is TEXT and the second data type is DMDB_CLOB; or The first data type is BOOLEAN and the second data type is DMDB_BOOLEAN; or The first data type is BLOB and the second data type is DMDB_BLOB.

3. The method according to claim 1 or 2, characterized in that, The connecting to the DM database through the database connection pool includes: Monitoring the load status of each database connection in the database connection pool; Allocating the database connection with the lightest load status to the ORM framework so that the ORM framework accesses the DM database through the database connection.

4. The method according to claim 1 or 2, characterized in that The converting the format of the return statement from the DM database to the format supported by the Sequelize component includes: Obtaining the operation result promise object from the DM database; Determining the return value in the last then field in the promise object; Converting the format of the return value to the format supported by the Sequelize component.

5. The method according to claim 1 or 2, characterized in that, The request statement is used to perform an add operation, a delete operation, a find operation, or a modify operation on the DM database.

6. An adaptation device for DM database, characterized in that, Including: A creation unit for generating a DM database operation code package based on the code package in the \lib\dialects\mysql directory of the Sequelize component; Placing the DM database operation code package in the \lib\dialects\ directory of the Sequelize component; Loading the DM database operation code package; Entering the driver class of the DM database according to the account information and service address; Invoking the creatTableQurey method in the driver class to create a database connection pool; A connection unit for connecting to the DM database through the database connection pool number; A conversion unit for converting a first data type from an ORM framework into a second data type supported by the DM database, creating a data type table supported by the DM database, and converting the format of a request statement from the ORM framework into a format supported by the DM database, and converting the format of a return result from the DM database into a format supported by the ORM framework.

7. A computer storage medium, characterized in that, The computer storage medium stores multiple instructions, and the instructions are suitable for being loaded and executed by a processor to perform the method steps of any one of claims 1 to 5.

8. A computer device, characterized in that, Comprising: A processor and a memory; wherein, the memory stores a computer program, and the computer program is suitable for being loaded and executed by the processor to perform the method steps of any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method and device for achieving efficient database access based on ORM (object relational mapping) architecture

    CN102841889A

  • Micro-service architecture intelligent database analysis adaptation method

    CN114153869A