Multi-data source SQL generation method and device, equipment and storage medium

By creating exploration data element models and providing general replacement templates, the problem of SQL script conversion of multidisciplinary seismic exploration model databases is solved, and compatibility of multiple databases is achieved and the effect of quickly generating SQL scripts is achieved.

CN120234336APending Publication Date: 2025-07-01CHINA NAT PETROLEUM CORP +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311867079.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-29
Publication Date
2025-07-01

AI Technical Summary

Technical Problem

The existing technology is difficult to achieve rapid conversion of multidisciplinary seismic exploration model database SQL scripts and compatibility of multi-source databases, resulting in limitations in data storage and migration.

Method used

By obtaining the E-R model of seismic exploration data, creating the corresponding exploration data element model, and providing access order and general replacement templates for different data sources, determining the general replacement template and access order of the target data source, and finally assembling the replacement value with the preset SQL script template to generate SQL scripts compatible with multiple databases.

Benefits of technology

It realizes fast SQL script generation and database structure transformation from E-R model to multiple relational databases (such as PG, Oracle, and SQLite), solves the compatibility problem of multi-source databases and improves the flexibility and efficiency of data migration and storage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120234336A_ABST
    Figure CN120234336A_ABST
Patent Text Reader

Abstract

The invention relates to a multi-data-source SQL generation method and device, equipment and a storage medium, and the method comprises the steps: creating a meta-model corresponding to each seismic exploration data E-R model; providing a corresponding meta-model element access sequence for each data source, and providing an original template and a universal replacement template corresponding to each data source for each element; providing element definition information corresponding to each data source, and writing the element definition information into a universal replacement template corresponding to each data source; determining a target general replacement template and a target access sequence corresponding to the target data source, accessing the elements according to the target access sequence, and determining replacement values of the elements by using the target general replacement template; and splicing the replacement values of the elements and the preset SQL script template to obtain the SQL script corresponding to the target data source, so that script features of various databases under multiple operating systems can be compatible, and various relational database SQL scripts can be quickly generated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of geophysical exploration, and particularly to a method and device for generating multi-source data SQL, a device, and a storage medium. Background Art

[0002] At present, domestic oil service companies are vigorously developing cross-platform and multi-storage digital oil and gas exploration services. The digital transformation deployments of major domestic oil and gas fields are strengthening the adaptation of mainstream multi-operating systems, and are also exploring various data source directions such as commercial databases Oracle, open-source databases PG, MySQL, and file databases sqlite. Exploration data accumulated by oilfield users at home and abroad over the years can be stored in relational databases such as Oracle, PG, sqlite, and OpenGauss. However, the data management system in the domestic seismic exploration industry mainly uses the Oracel single-source database. Potential domestic market users have been looking for new enterprise-level and high-performance data sources, expecting to make qualitative discoveries in the direction of multi-source and open-source storage. However, due to its deep coupling and multi-disciplinary intersection, the SQL script of the database based on the multi-disciplinary seismic exploration model has become one of the key limitations for the conversion of SQL scripts of multiple data sources to multi-source seismic exploration data storage.

[0003] Core mainstream geophysical exploration software represented by GeoEast (an integrated software system for seismic data processing and interpretation) is currently exploring in multiple aspects such as cross-platform, open-source databases, and file-based data management. The management of underlying model scripts has become a barrier when facing cross-platform and multi-source databases. Currently, there are mainly two solutions: commercial software, which has insufficient decoupling of the associations between models; and pure manual work, which results in low efficiency and extremely high error rates.

[0004] With the development of oil and gas exploration and the continuous expansion of multi-disciplinary data models, it is an urgent need to achieve flexible installation of multi-disciplinary and multi-databases from the aspects of rapid deployment and security of exploration data, that is, to quickly generate multi-source data SQL. At present, domestic exploration has just started to research file databases and open-source databases, and only supports the conversion of PG single-source database scripts. Other industry software uses commercial software or script conversion based on general plugins for multi-source databases, which cannot guarantee the completeness of models and has great limitations for applications after data migration. Summary of the Invention

[0005] In order to solve the above technical problems or at least partially solve the above technical problems, embodiments of the present disclosure provide a method and device for generating multi-source data SQL, a device, and a storage medium.

[0006] In a first aspect, embodiments of the present disclosure provide a method for generating multi-source data SQL, including:

[0007] Obtain at least one seismic exploration data E-R model. For each seismic exploration data E-R model, create an exploration data meta-model corresponding to the seismic exploration data E-R model;

[0008] Provide the access order of the exploration data meta-model elements corresponding to each data source, and provide an original template for each element in the exploration data meta-model and a general replacement template corresponding to each data source respectively;

[0009] Provide the element definition information corresponding to each data source respectively, and write the element definition information into the general replacement template corresponding to each data source;

[0010] Determine the target general replacement template corresponding to the target data source and the target access order of the exploration data meta-model elements. Access and obtain the elements in the exploration data meta-model according to the target access order, and use the target general replacement template to determine the replacement values of the elements in the exploration data meta-model;

[0011] Assemble the replacement values of the elements in the exploration data meta-model with a preset SQL script template to obtain an SQL script corresponding to the target data source.

[0012] In a possible implementation manner, the creating of the exploration data meta-model corresponding to the seismic exploration data E-R model includes:

[0013] Obtain the storage location path of the seismic exploration data E-R model, traverse all E-R models under the storage location path. For each seismic exploration data E-R model, extract various constraint relationships in the seismic exploration data E-R model, describe the general structure I of the seismic exploration data according to the quadruple data model, and record all elements of the general structure to form an I set. Among them, the elements of the general structure include a single model model, a controller control, a relation relation, and a foreign foreign of the exploration data E-R model;

[0014] For all I sets, create the root node of xml, and create under the root node <imodels>Label; at <imodels>Create in the label <imodel>Label; at <imodel>Create in the label <describes>Label <control>Label, <relation>Label and <foreign>Label; at <describes>Create in the label <info>Label; Fill in the description information of the elements in set I in the fields of the label to generate an xml model description file, which serves as the exploration data meta-model corresponding to the seismic exploration data E-R model.

[0015] In a possible implementation, the single model includes the names and types of columns; the controller includes built-in functions; the association includes primary keys, unique keys, and triggers; the external includes foreign keys and external functions.

[0016] In a possible implementation, provide the access order of the exploration data meta-model elements corresponding to each data source, and provide an original template and a general replacement template corresponding to each data source for each element in the exploration data meta-model, including:

[0017] From the xml model description file, obtain all model tags, extract the general information of the elements, separate them into four types: single model model, controller control, association relation, and external foreign, respectively, and perform a deduplication operation based on the name of each tag to retain the unique record elements;

[0018] For each element information separated from the model tag, create the smallest unit of the I model domain. Among them, the smallest unit of the I model domain includes 4 element tags: Imodel, Icontrol, Ireation, and Iforeign. Each element tag serves as a smallest unit controller, and an id field is created in the smallest unit tag of the I model domain to control the access order of the smallest unit. The original template and multiple general replacement templates are defined under each smallest unit controller.

[0019] In a possible implementation, the provision of element definition information corresponding to each data source includes:

[0020] Obtain the databases corresponding to each data source respectively, create database drivers corresponding to each database respectively, and obtain database connection handles according to the configuration information of the databases;

[0021] Using the database handle, obtain the definition information of the functions in the data dictionary of the database for the current database, the definition information of the triggers of the current database; and the definition information of the tables, columns, and data types of the current database;

[0022] Write the definition information in the database dictionary into the general replacement template, where the database field in the general replacement template is the type of the current database.

[0023] In a possible implementation manner, the preset SQL script template includes the positions of operation characters, schema names, placeholders, table names, views, value range symbol sets, value sets, and end characters.

[0024] In a possible implementation manner, assembling the replacement values of the elements in the exploration data meta-model with the preset SQL script template to obtain an SQL script corresponding to the target data source includes:

[0025] Writing the replacement values of the elements in the exploration data meta-model into the corresponding positions of operation characters, schema names, placeholders, table names, views, value range symbol sets, value sets, and end characters in the preset SQL script template to obtain an SQL script corresponding to the target data source.

[0026] In a second aspect, an embodiment of the present disclosure provides a multi-data source SQL generation device, including:

[0027] A creation module, configured to obtain at least one seismic exploration data E-R model, and for each seismic exploration data E-R model, create an exploration data meta-model corresponding to the seismic exploration data E-R model;

[0028] A providing module, configured to provide the access order of the elements of the exploration data meta-model corresponding to each data source, and provide an original template and a general replacement template corresponding to each data source for each element in the exploration data meta-model;

[0029] A writing module, configured to provide element definition information corresponding to each data source, and write the element definition information into the general replacement template corresponding to each data source;

[0030] A determination module, configured to determine a target general replacement template corresponding to the target data source and a target access order of the elements of the exploration data meta-model, access and obtain the elements in the exploration data meta-model according to the target access order, and determine the replacement values of the elements in the exploration data meta-model by using the target general replacement template;

[0031] An assembling module, configured to assemble the replacement values of the elements in the exploration data meta-model with the preset SQL script template to obtain an SQL script corresponding to the target data source.

[0032] In a third aspect, an embodiment of the present disclosure provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory communicate with each other through the communication bus;

[0033] The memory is used to store a computer program;

[0034] A processor, when executing a program stored in a memory, implements the above multi-data-source SQL generation method.

[0035] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium, on which a computer program is stored, characterized in that when the computer program is executed by a processor, the above multi-data-source SQL generation method is implemented.

[0036] The above technical solutions provided by the embodiments of the present disclosure have at least some or all of the following advantages compared with the prior art:

[0037] In the multi-data-source SQL generation method described in the embodiments of the present disclosure, at least one seismic exploration data E-R model is obtained. For each seismic exploration data E-R model, an exploration data meta-model corresponding to the seismic exploration data E-R model is created; an access order of exploration data meta-model elements corresponding to each data source is provided, and an original template and a general replacement template corresponding to each data source are provided for each element in the exploration data meta-model; element definition information corresponding to each data source is provided, and the element definition information is written into the general replacement template corresponding to each data source; a target general replacement template corresponding to the target data source and a target access order of exploration data meta-model elements are determined, the elements in the exploration data meta-model are accessed and obtained according to the target access order, and the replacement values of the elements in the exploration data meta-model are determined by using the target general replacement template; the replacement values of the elements in the exploration data meta-model and a preset SQL script template are assembled to obtain an SQL script corresponding to the target data source, which can be compatible with the script characteristics of multiple databases under multiple operating systems, solves the problem of quickly generating SQL scripts for multiple relational databases such as PG, oracle, sqlite, etc., and realizes the rapid conversion from an E-R model to a database structure. Description of the Drawings

[0038] The drawings here are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure.

[0039] To more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or related technologies. Obviously, for those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0040] Figure 1 Schematically shows a flowchart of a multi-data-source SQL generation method according to an embodiment of the present disclosure;

[0041] Figure 2 Schematic diagram showing a preset SQL script template according to an embodiment of the present disclosure;

[0042] Figure 3 Schematic diagram showing the performance test of reading data from a well single table of a seismic exploration model in a single-person and single-machine scenario for the multi-data-source SQL generation method according to an embodiment of the present disclosure;

[0043] Figure 4 Schematic block diagram showing the structure of a multi-data-source SQL generation device according to an embodiment of the present disclosure; and

[0044] Figure 5 Schematic block diagram showing the structure of an electronic device according to an embodiment of the present disclosure. Detailed implementation manners

[0045] To make the objectives, technical solutions, and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure. Apparently, the described embodiments are some, but not all, of the embodiments of the present disclosure. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present disclosure without creative efforts shall fall within the protection scope of the present disclosure.

[0046] Refer to Figure 1 , an embodiment of the present disclosure provides a multi-data-source SQL generation method, including:

[0047] S1. Obtain at least one seismic exploration data E-R model, and for each seismic exploration data E-R model, create an exploration data meta-model corresponding to the seismic exploration data E-R model.

[0048] In this embodiment, the seismic exploration data E-R model is composed of multiple exploration disciplines such as processing, interpretation, reservoir, well, and vertical seismic profile. The conversion and construction of the data model from its entity concept model to the database are completed through SQL scripts. Among them, the SQL scripts contain various design concepts such as library structure, table structure, domain, value range, constraint conditions, and built-in functions, and are also the core of the bottom-layer data engine for constructing massive seismic exploration data at the oilfield basin level.

[0049] In this embodiment, the exploration data meta-model is a model that describes the seismic exploration data E-R model. In the database field, the meta-model is the definition of database objects, including: tables, columns, primary keys, foreign keys, unique keys, etc.

[0050] S2. Provide the access order of the exploration data meta-model elements corresponding to each data source, and provide an original template and a general replacement template corresponding to each data source for each element in the exploration data meta-model.

[0051] S3. Provide element definition information corresponding to each data source respectively, and write the element definition information into the general replacement template corresponding to each data source.

[0052] S4. Determine the target general replacement template corresponding to the target data source and the target access order of the elements of the exploration data meta-model, access and obtain the elements in the exploration data meta-model according to the target access order, and use the target general replacement template to determine the replacement values of the elements in the exploration data meta-model.

[0053] S5. Assemble the replacement values of the elements in the exploration data meta-model with a preset SQL script template to obtain an SQL script corresponding to the target data source, where the preset SQL script template is as Figure 2 shown.

[0054] In this embodiment, in step S1, the creation of the exploration data meta-model corresponding to the seismic exploration data E-R model includes:

[0055] Obtain the storage location path of the seismic exploration data E-R model, traverse all E-R models under the storage location path. For each seismic exploration data E-R model, extract various constraint relationships in the seismic exploration data E-R model, describe the general structure I of the seismic exploration data according to the quadruple data model, and record all elements of the general structure to form an I set. Among them, the elements of the general structure include a single model model, a controller control, a relation relation, and a foreign foreign of the exploration data E-R model. The single model includes the name and type of columns; the controller includes built-in functions; the relation includes a primary key, a unique key, and a trigger; the foreign includes a foreign key and an external function;

[0056] For all I sets, create the root node of the xml, and create <imodels>Label; at <imodels>Create in the label <imodel>Label; at <imodel>Create in the label <describes>Label, <control>Label, <relation>Label and <foreign>Label; at <describes>Create in the label <info>Label; Fill in the description information of the elements in set I in the fields of the label to generate an xml model description file, which serves as the exploration data meta-model corresponding to the seismic exploration data E-R model.

[0057] In some embodiments, <imodels>The fields of the label include but are not limited to type, id, datasource, ip, port; <imodel>The fields of the label include but are not limited to the name; <describes>The fields of the label include but are not limited to type, id, and strtype; <control>The fields of the label include but are not limited to type, id, and strtype; <relation>The fields of the label include but are not limited to type, id, and strtype; <foreign>The fields of the label include but are not limited to type, id, and strtype; <info>The fields of the label include but are not limited to type, primary key (PK), and foreign key (FK).

[0058] In this embodiment, in step S2, providing an access order for the exploration data meta-model elements corresponding to each data source, and providing an original template and a general replacement template corresponding to each data source for each element in the exploration data meta-model, includes:

[0059] Obtain all model tags from the xml model description file, extract the general information of the elements, separate them into four types: single model (model), controller (control), association (relation), and external (foreign) respectively, and perform a de-duplication operation based on the name of each tag to retain the unique record elements;

[0060] For each element information separated from the model tags, create a minimum unit of the I model domain. Among them, the minimum unit of the I model domain includes 4 element tags: Imodel, Icontrol, Ireation, and Iforeign. Each element tag serves as a minimum unit controller, and an id field is created in the I model domain minimum unit tag to control the access order of the minimum unit. The original template and multiple general replacement templates are defined under each minimum unit controller.

[0061] In this embodiment, since different databases have different definition formats for the I set, when executing the access instruction, it is necessary to access in the order of the minimum unit of the I model domain.

[0062] In this embodiment, the fields of the minimum unit of the I model domain include label type, id field, data source, database, ip address, and port. The fields of the original template include but are not limited to table, name, and type; the fields of the general replacement template include but are not limited to database, table, name, and type.

[0063] In this embodiment, the model element contains table name, column name, and column attribute. In the case of multiple column names with the same name (created_by), only the first created_by column name is saved, and the rest are deleted to achieve the de-duplication operation.

[0064] In this embodiment, in step S3, providing the element definition information corresponding to each data source respectively, includes:

[0065] Obtain the databases corresponding to each data source respectively, create database drivers corresponding to each database respectively, and obtain database connection handles according to the configuration information of the databases, where the configuration information includes IP address, port, database name, and storage path;

[0066] Using the database handle, obtain the definition information of the functions in the data dictionary of the database for the current database, the trigger definition information for the current database; and the definition information of the tables, columns, and data type information in the current database;

[0067] Write the definition information in the database dictionary into the general replacement template, where the database field in the general replacement template is the type of the current database.

[0068] In this embodiment, after obtaining the SQL script corresponding to the target data source, the method further includes: calling the execution script interface of the database handle to perform a data writing operation on the SQL script to complete the creation of the database model corresponding to the target data source.

[0069] In this embodiment, in step S5, the preset SQL script template includes the positions of operation characters, schema names, placeholders, table names, views, value range symbol sets, value sets, and ending characters. Assembling the replacement values of the elements in the exploration data meta-model with the preset SQL script template to obtain the SQL script corresponding to the target data source includes:

[0070] Write the replacement values of the elements in the exploration data meta-model into the corresponding positions of the operation characters, schema names, placeholders, table names, views, value range symbol sets, value sets, and ending characters in the preset SQL script template to obtain the SQL script corresponding to the target data source.

[0071] As Figure 3 shown, in the case of single-person single-machine, use the multi-data-source SQL generation method of the present disclosure to perform a read data performance test on the well single table of the seismic exploration model. In the case of single-machine single-user, perform read and write operations on the seismic exploration work area, grid, seismic data, horizon data, etc., and store them in the PG database and the sqlite database respectively. The throughput performance of the interface data is greatly improved, and the seismic exploration data stored in the PG database or the sqlite database can be normally displayed.

[0072] In the case of creating a POSTGRESQL database model for seismic exploration data, according to the configuration information such as the IP, port, and database name of the POSTGRESQL database, obtain the POSTGRESQL database connection handle and the POSTGRESQL database dictionary, and write the definition information in the POSTGRESQL database dictionary into the general replacement template corresponding to the POSTGRESQL database.

[0073] In the case of creating an SQLite database model for seismic exploration data, according to the configuration information such as the IP, port, and database name of the SQLite database, obtain the SQLite database connection handle and the SQLite database dictionary, and write the definition information in the SQLite database dictionary into the corresponding general replacement template of the SQLite database.

[0074] The multi-data-source SQL generation method of the present disclosure uses the data dictionary of data types to shield the difference details of different databases, quickly converts and creates tables in the database, adds, deletes, or changes the domain of definition of semantics such as columns in existing data tables, and performs fast SQL conversion for multi-source databases. It solves the complex problem of multi-disciplinary model coupling in database storage, greatly reduces the coupling degree between the database and the business logic layer, can describe the massive databases of large systems, improves the secondary utilization rate of data assets, enhances work efficiency, saves development costs, can also describe the seismic exploration integration model globally, and has expandable elasticity, and can dynamically support operations such as later reservoir, acquisition, and basin construction.

[0075] See Figure 4 , an embodiment of the present disclosure provides a multi-data-source SQL generation device, including:

[0076] A creation module 11, configured to obtain at least one seismic exploration data E-R model, and for each seismic exploration data E-R model, create an exploration data meta-model corresponding to the seismic exploration data E-R model;

[0077] A providing module 12, configured to provide the access order of the exploration data meta-model elements corresponding to each data source, and provide an original template and a general replacement template corresponding to each data source for each element in the exploration data meta-model;

[0078] A writing module 13, configured to provide the element definition information corresponding to each data source, and write the element definition information into the general replacement template corresponding to each data source;

[0079] A determination module 14, configured to determine the target general replacement template corresponding to the target data source and the target access order of the exploration data meta-model elements, access and obtain the elements in the exploration data meta-model according to the target access order, and determine the replacement values of the elements in the exploration data meta-model by using the target general replacement template;

[0080] An assembly module 15, configured to assemble the replacement values of the elements in the exploration data meta-model with a preset SQL script template to obtain an SQL script corresponding to the target data source.

[0081] For the implementation process of the functions and roles of each unit in the above device, please refer to the implementation process of the corresponding steps in the above method for details, which will not be elaborated here.

[0082] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can be referred to the partial description of the method embodiment. The device embodiments described above are only illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of the present invention. Those of ordinary skill in the art can understand and implement it without creative efforts.

[0083] In the above embodiments, any combination of the creation module 11, the providing module 12, the writing module 13, the determining module 14, and the assembling module 15 can be combined and implemented in one module, or any one of the modules can be split into multiple modules. Or, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. At least one of the creation module 11, the providing module 12, the writing module 13, the determining module 14, and the assembling module 15 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by any other reasonable way of integrating or packaging circuits, etc., in hardware or firmware, or implemented in any one of the three implementation ways of software, hardware, and firmware, or in any appropriate combination of several of them. Or, at least one of the creation module 11, the providing module 12, the writing module 13, the determining module 14, and the assembling module 15 can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding functions can be executed.

[0084] Referring to Figure 5 As shown, the electronic device provided by the embodiment of the present disclosure includes a processor 1110, a communication interface 1120, a memory 1130, and a communication bus 1140. Among them, the processor 1110, the communication interface 1120, and the memory 1130 complete mutual communication through the communication bus 1140;

[0085] The memory 1130 is used to store a computer program;

[0086] When the processor 1110 is used to execute the program stored in the memory 1130, the following multi-data source SQL generation method is implemented:

[0087] Obtain at least one seismic exploration data E-R model. For each seismic exploration data E-R model, create an exploration data meta-model corresponding to the seismic exploration data E-R model;

[0088] Provide the access order of the exploration data meta-model elements corresponding to each data source, and provide an original template and a general replacement template corresponding to each data source for each element in the exploration data meta-model;

[0089] Provide element definition information corresponding to each data source, and write the element definition information into the general replacement template corresponding to each data source;

[0090] Determine the target general replacement template corresponding to the target data source and the target access order of the exploration data meta-model elements. Access and obtain the elements in the exploration data meta-model according to the target access order, and use the target general replacement template to determine the replacement values of the elements in the exploration data meta-model;

[0091] Assemble the replacement values of the elements in the exploration data meta-model with a preset SQL script template to obtain an SQL script corresponding to the target data source.

[0092] The above communication bus 1140 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus 1140 can be divided into an address bus, a data bus, a control bus, etc. For the sake of representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0093] The communication interface 1120 is used for communication between the above electronic device and other devices.

[0094] The memory 1130 can include a Random Access Memory (RAM), and can also include a non-volatile memory, such as at least one disk memory. Optionally, the memory 1130 can also be at least one storage device located far from the aforementioned processor 1110.

[0095] The above-mentioned processor 1110 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0096] Embodiments of the present disclosure also provide a computer-readable storage medium. A computer program is stored on the above-mentioned computer-readable storage medium, and when the above-mentioned computer program is executed by a processor, the multi-data source SQL generation method described above is implemented.

[0097] The computer-readable storage medium may be included in the device / device described in the above embodiments; it may also exist alone and not be assembled into the device / device. The above-mentioned computer-readable storage medium carries one or more programs, and when the above-mentioned one or more programs are executed, the multi-data source SQL generation method according to the embodiments of the present disclosure is implemented.

[0098] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, it may include but is not limited to: portable computer disks, hard disks, random access memories (RAMs), read-only memories (ROMs), erasable programmable read-only memories (EPROMs or flash memories), portable compact disk read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, or any suitable combination of the above. In the present disclosure, the computer-readable storage medium may be any tangible medium that contains or stores a program, and the program may be used by or in combination with an instruction execution system, device, or device.

[0099] It should be noted that in this text, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variation thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the said element.

[0100] The above are only specific embodiments of the present disclosure, enabling those skilled in the art to understand or implement the present disclosure. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to these embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.< / info> < / foreign> < / relation> < / control> < / describes> < / imodel> < / imodels> < / info> < / describes> < / foreign> < / relation> < / control> < / describes> < / imodel> < / imodel> < / imodels> < / imodels> < / info> < / describes> < / foreign> < / relation> < / control> < / describes> < / imodel> < / imodel> < / imodels> < / imodels>

Claims

1. A method for generating SQL of multiple data sources, characterized in that, The method includes: Obtain at least one seismic exploration data E-R model. For each seismic exploration data E-R model, create an exploration data meta-model corresponding to the seismic exploration data E-R model; Provide the access order of the exploration data meta-model elements corresponding to each data source, and provide an original template and a general replacement template corresponding to each data source for each element in the exploration data meta-model; Provide the element definition information corresponding to each data source, and write the element definition information into the general replacement template corresponding to each data source; Determine the target general replacement template corresponding to the target data source and the target access order of the exploration data meta-model elements. Access and obtain the elements in the exploration data meta-model according to the target access order, and use the target general replacement template to determine the replacement values of the elements in the exploration data meta-model; Assemble the replacement values of the elements in the exploration data meta-model with the preset SQL script template to obtain the SQL script corresponding to the target data source.

2. The method according to claim 1, wherein The creation of the exploration data meta-model corresponding to the seismic exploration data E-R model includes: Obtain the storage location path of the seismic exploration data E-R model, traverse all E-R models under the storage location path. For each seismic exploration data E-R model, extract various constraint relationships in the seismic exploration data E-R model, describe the general structure I of the seismic exploration data according to the quadruple data model, and record all elements of the general structure to form an I set. Among them, the elements of the general structure include a single model model, a controller control, a relationship relation, and an external foreign of the exploration data E-R model; For all sets of I, create the root node of the xml and create <imodels>Label; at <imodels>Create in the label <imodel>Label; at <imodel>Create in the label <describes>Label <control>Label <relation>Label and <foreign>Label; at <describes>Create in the label <info>Label; fill in the description information of the elements of the I set in the fields in the label to generate an xml model description file as the exploration data meta-model corresponding to the seismic exploration data E-R model.< / info> < / describes> < / foreign> < / relation> < / control> < / describes> < / imodel> < / imodel> < / imodels> < / imodels> 3. The method according to claim 2, wherein The single model includes the name and type of columns; the controller includes built-in functions; the relationship includes primary keys, unique keys, and triggers; the external includes foreign keys and external functions.

4. The method according to claim 2, wherein The providing the access order of the exploration data meta-model elements corresponding to each data source, and providing an original template and a general replacement template corresponding to each data source for each element in the exploration data meta-model includes: From the xml model description file, obtain all model tags, extract the general information of the elements, separate them according to the four types of single model model, controller control, relationship relation, and external foreign respectively, and perform a de-duplication operation based on the name of each tag to retain the unique recorded elements; For each piece of element information separated from the model tag, create the smallest unit of the I model domain. Among them, the smallest unit of the I model domain includes 4 element tags: Imodel, Icontrol, Ireation, and Iforeign. Each element tag serves as a smallest unit controller, and an id field is created in the I model domain smallest unit tag to control the access order of the smallest unit. Under each smallest unit controller, an original template and multiple general replacement templates are defined.

5. The method according to claim 1, characterized in that The provided element definition information corresponding to each data source includes: Obtain the database corresponding to each data source, create a database driver corresponding to each database, and obtain a database connection handle according to the configuration information of the database; Using the database handle, obtain the definition information of the functions in the data dictionary of the database for the current database, the trigger definition information for the current database; and the definition information of the tables, columns, and data type information of the current database; Write the definition information in the database dictionary into the general replacement template, where the database field in the general replacement template is the type of the current database.

6. The method according to claim 1, wherein The preset SQL script template includes the positions of operation characters, schema names, placeholders, table names, views, value range symbol sets, value sets, and ending characters.

7. The method according to claim 6, wherein The assembly of the replacement values of the elements in the exploration data meta-model and the preset SQL script template to obtain the SQL script corresponding to the target data source includes: Write the replacement values of the elements in the exploration data meta-model into the positions of the corresponding operation characters, schema names, placeholders, table names, views, value range symbol sets, value sets, and ending characters in the preset SQL script template to obtain the SQL script corresponding to the target data source.

8. A multi-data-source SQL generation device, characterized in that, Includes: A creation module for obtaining at least one seismic exploration data E-R model, and for each seismic exploration data E-R model, creating an exploration data meta-model corresponding to the seismic exploration data E-R model; A provision module for providing the access order of the exploration data meta-model elements corresponding to each data source, and providing an original template and general replacement templates corresponding to each data source for each element in the exploration data meta-model; A writing module for providing element definition information corresponding to each data source and writing the element definition information into the general replacement template corresponding to each data source; A determination module for determining the target general replacement template corresponding to the target data source and the target access order of the exploration data meta-model elements, accessing and obtaining the elements in the exploration data meta-model according to the target access order, and using the target general replacement template to determine the replacement values of the elements in the exploration data meta-model; An assembly module for assembling the replacement values of the elements in the exploration data meta-model and the preset SQL script template to obtain the SQL script corresponding to the target data source.

9. An electronic device, characterized in that, Includes a processor, a communication interface, a memory, and a communication bus. Among them, the processor, communication interface, and memory complete communication with each other through the communication bus; The memory is used to store computer programs; A processor, when executing a program stored in a memory, implements the multi-data-source SQL generation method according to any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the multi-data-source SQL generation method according to any one of claims 1-7.