Database table information recording method and device
By generating shell scripts and using Git warehouse to automatically process database table information, the high difficulty problems brought about by manual maintenance are solved, and the automated maintenance and differential recording of database table information is realized, and information integrity is improved.
Patent Information
- Application Number
- CN202111659549.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-30
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2041-12-30
AI Technical Summary
In the prior art, the maintenance and recording of database table information relies on manual operations, which makes work difficult and easy to miss, affecting the subsequent development process.
By obtaining the information of multiple databases, generating shell scripts, reading database table information, generating md files, and using Git repository to convert them into initial data dictionary, comparing with historical data dictionary, automatically recording differences, and generating current data dictionary.
Automatic maintenance and differential recording of database table information is realized, reducing the work difficulty of technicians and ensuring information integrity.
Smart Images

Figure CN114265847B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of information management, and in particular to a method and device for recording database table information. Background Art
[0002] Database table information contains relevant information such as the database table structure. During enterprise-level development, technical personnel usually compile corresponding database table information based on the database information of the database, and use the database table information to describe the database structure, index, and basic database information.
[0003] In the existing technology, technical personnel manually maintain documentation related to database table information. Changes to the database table structure, for example, require further documentation and maintenance, which increases the difficulty and workload for technical personnel. In later development processes, forgetting to maintain and record information can easily lead to information loss, making subsequent work more difficult. Summary of the Invention
[0004] In view of this, the present invention provides a method and device for recording database table information, wherein the method can automatically maintain the database table information of the database and record the relevant differences, thereby reducing the difficulty of subsequent work.
[0005] A method for recording database table information, comprising:
[0006] Get database information of multiple preset databases;
[0007] Based on the database information of each database, generating a Shell script corresponding to each database;
[0008] Applying the Shell script to read database table information of each of the databases;
[0009] Generate an md file corresponding to each database based on the database information and the database table information;
[0010] Send each of the md files to the Git repository, and use the Git repository to convert the md files into an initial data dictionary;
[0011] The initial data dictionary is compared with the historical data dictionary generated last time to obtain a comparison result, and the initial data dictionary is updated based on the comparison result to obtain a current data dictionary corresponding to each of the databases.
[0012] Optionally, in the above method, obtaining database information of a plurality of preset databases includes:
[0013] Receive user maintenance information uploaded by users, the user maintenance information including data update strategy, data classification and data source;
[0014] Write the user maintenance information into the template file preset in the Git repository, and monitor in real time whether the current environment meets the data update strategy;
[0015] If the current environment satisfies the data update strategy, each of the databases is connected to obtain database information of each of the databases.
[0016] Optionally, the method described above includes applying the Shell script to read the database table information of each database, including:
[0017] Determining the reading order of each of the databases according to a preset sorting rule;
[0018] Apply the plsq instruction in the Shell script to read the database table information of each database in sequence according to the reading order.
[0019] Optionally, the above method generates an md file corresponding to each database based on the database information and the database table information, including:
[0020] Obtaining the database name of the database corresponding to each database information contained in the database information, and generating a first-level menu md file corresponding to each database based on each database name, wherein each first-level menu md file is used to point to its corresponding database;
[0021] Based on the database table information corresponding to each of the databases, determine each database table contained in each of the databases, and generate a secondary menu md file corresponding to each of the database tables;
[0022] Obtaining basic table information, table structure information, table index information, and table data example information from each of the database table information;
[0023] Generate detailed table information corresponding to each database table based on basic table information, table structure information, table index information, and table data example information in each database table information;
[0024] Based on the first-level menu md file, the second-level menu md file and the table detailed information, an md file corresponding to each of the databases is generated.
[0025] Optionally, the method described above includes comparing the initial data dictionary with a previously generated historical data dictionary to obtain a comparison result, and updating the initial data dictionary based on the comparison result, including:
[0026] Based on the information of each database table, determine the current database summary information corresponding to each database, and save the database summary information to the initial data dictionary, wherein the database summary information includes the number of database tables and the total amount of database record data;
[0027] Obtaining the historical database summary information stored in the historical data dictionary;
[0028] Comparing the current database summary information with the historical database summary information to determine difference information between the initial data dictionary and the historical data dictionary;
[0029] The difference information is updated to the change record of the initial data dictionary.
[0030] A database table information recording device, comprising:
[0031] An acquisition unit, configured to acquire database information of a plurality of preset databases;
[0032] A first generating unit, configured to generate a Shell script corresponding to each of the databases based on the database information of each of the databases;
[0033] A reading unit, configured to apply the Shell script to read database table information of each of the databases;
[0034] A second generating unit is configured to generate an md file corresponding to each of the databases based on the database information and the database table information;
[0035] A third generating unit is configured to send each of the md files to the Git repository and convert the md files into an initial data dictionary using the Git repository;
[0036] An updating unit is configured to compare the initial data dictionary with a previously generated historical data dictionary to obtain a comparison result, and update the initial data dictionary based on the comparison result to obtain a current data dictionary corresponding to each of the databases.
[0037] In the above device, optionally, the acquisition unit includes:
[0038] A receiving subunit, configured to receive user maintenance information uploaded by a user, wherein the user maintenance information includes data update strategy, data classification and data source;
[0039] A monitoring subunit is used to write the user maintenance information into a template file preset in the Git repository and monitor in real time whether the current environment meets the data update strategy;
[0040] The first acquisition subunit is configured to connect to each of the databases and acquire database information of each of the databases if the current environment satisfies the data update strategy.
[0041] In the above device, optionally, the reading unit includes:
[0042] a determination subunit, configured to determine a reading order of each of the databases according to a preset sorting rule;
[0043] The reading subunit is used to apply the plsq instruction in the Shell script to sequentially read the database table information of each of the databases according to the reading order.
[0044] In the above device, optionally, the second generating unit includes:
[0045] The second acquisition subunit is configured to acquire a database name of a database corresponding to each database information contained in the database information, and generate a first-level menu md file corresponding to each database based on each database name, wherein each first-level menu md file is used to point to its corresponding database;
[0046] A first generating subunit is configured to determine each database table contained in each database based on database table information corresponding to each database, and generate a secondary menu md file corresponding to each database table;
[0047] A third acquisition subunit is configured to acquire basic table information, table structure information, table index information, and table data example information from each of the database table information;
[0048] A second generating subunit is configured to generate detailed table information corresponding to each of the database tables based on the basic table information, table structure information, table index information, and table data example information in each of the database table information;
[0049] The third generating subunit is used to generate an md file corresponding to each of the databases based on the first-level menu md file, the second-level menu md file and the table detailed information.
[0050] In the above device, optionally, the updating unit includes:
[0051] a storage unit, configured to determine, based on the information of each database table, current database summary information corresponding to each database, and save the database summary information to the initial data dictionary, wherein the database summary information includes the number of database tables and the total amount of database record data;
[0052] A fourth acquisition subunit is used to acquire the historical database summary information stored in the historical data dictionary;
[0053] a comparing subunit, configured to compare the current database summary information with the historical database summary information to determine difference information between the initial data dictionary and the historical data dictionary;
[0054] The updating subunit is configured to update the difference information to the change record of the initial data dictionary.
[0055] A storage medium includes stored instructions, wherein when the instructions are executed, the device where the storage medium is located is controlled to execute the above-mentioned database table information recording method.
[0056] An electronic device includes a memory and one or more instructions, wherein the one or more instructions are stored in the memory and configured to be executed by one or more processors to perform the above-mentioned database table information recording method.
[0057] Compared with the prior art, the present invention has the following advantages:
[0058] The present invention provides a method for recording database table information, comprising: obtaining database information of a plurality of preset databases; generating a shell script corresponding to each database based on the database information of each database; applying the shell script to read the database table information of each database; generating an md file corresponding to each database based on the database information and the database table information; sending each md file to a Git repository, and converting the md file into an initial data dictionary using the Git repository; comparing the initial data dictionary with a previously generated historical data dictionary to obtain a comparison result, and updating the initial data dictionary based on the comparison result to obtain a current data dictionary corresponding to each database. The method provided by the present invention can automatically maintain the database table information of a database and record relevant differences, thereby reducing the difficulty of subsequent work. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0060] Figure 1 A method flow chart of a method for recording database table information provided by an embodiment of the present invention;
[0061] Figure 2An example diagram of a template file provided in an embodiment of the present invention;
[0062] Figure 3 An example diagram of a Shell script provided in an embodiment of the present invention;
[0063] Figure 4 A flowchart of another method for recording database table information provided by an embodiment of the present invention;
[0064] Figure 5 An example diagram of a data dictionary provided by an embodiment of the present invention;
[0065] Figure 6 A flowchart of another method for recording database table information provided by an embodiment of the present invention;
[0066] Figure 7 A diagram showing the structure of a device for recording database table information provided by an embodiment of the present invention;
[0067] Figure 8 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0068] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0069] In this application, relational terms such as first and second are used only 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. The terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or apparatus comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or apparatus comprising the element.
[0070] The present invention can be used in a variety of general or special computing device environments or configurations, such as personal computers, server computers, handheld or portable devices, tablet devices, multi-processor devices, distributed computing environments including any of the above devices or devices, and the like.
[0071] The embodiment of the present invention provides a method for recording database table information. The method can be applied to various system platforms. The execution subject can be a computer terminal or a processor of various mobile devices. The method flow chart of the method is shown in FIG. Figure 1 As shown, specifically including:
[0072] S101: Obtain database information of multiple preset databases.
[0073] Specifically, the database information includes the database name, database IP address, and database identifier.
[0074] Furthermore, the specific process of obtaining data information of each database includes:
[0075] Receive user maintenance information uploaded by the user, wherein the user maintenance information includes data update strategy, data classification and data source.
[0076] In addition to data update strategies, data classifications, and data sources, user maintenance information also includes index information, data instances, etc. User update strategies are user-defined timelines for recording database table information, such as real-time updates or daily updates at 8:10 AM.
[0077] The user maintenance information is written into a template file preset in the Git repository, and the current environment is monitored in real time to see if it meets the data update strategy.
[0078] like Figure 2 As shown, Figure 2 It is a template file, which includes description items and specific descriptions for each description item. The description part is user maintenance information uploaded by the user and related information of system settings.
[0079] If the current environment satisfies the data update strategy, each of the databases is connected to obtain database information of each of the databases.
[0080] It is understandable that if the current time point reaches the time point set in the update strategy, the database is connected to obtain the database information of the database.
[0081] It should be noted that, in the embodiment of the present invention, the database information is acquired according to the set update strategy and the subsequent data dictionary generation process from S102 to S106 is executed.
[0082] S102: Based on the database information of each database, generate a Shell script corresponding to each database.
[0083] Specifically, database information configuration: put the database information in the .sh file. One Shell script represents one database information. Multiple data sources exist in different Shell scripts.
[0084] Optionally, during the database configuration, you can also configure the Git repository to be password-free. To generate the SSH private and public keys, use the following Linux command: ssh-keygen-trsa -N" -f ~ / .ssh / id_rsa> / dev / null . Place the generated id_rsa and id_rsa.pub files in the script project's ssh directory and add the contents of the id_rsa.pub public key to the Git repository's md document project.
[0085] like Figure 3 As shown, Figure 3 The present invention provides a Shell script generated based on database information, which includes database name, IP address, and database identifier.
[0086] S103: Apply the Shell script to read the database table information of each database.
[0087] It can be understood that the database table information of the database is read through the relevant instructions of the Shell script.
[0088] Furthermore, the process of applying the Shell script to read the database table information of each of the databases may include:
[0089] Determining the reading order of each of the databases according to a preset sorting rule;
[0090] Apply the plsq instruction in the Shell script to read the database table information of each database in sequence according to the reading order.
[0091] Specifically, each database is sorted, and the database table information of each database is read in sequence according to the sort order. A single database connection information is obtained through a for loop, and the plsq instruction is used to connect to the database and query the database table information.
[0092] S104: Based on the information of each database and the information of each database table, generate an md file corresponding to each database.
[0093] It should be noted that md file is Markdown file. Markdown is a lightweight markup language. Git repository supports Markdown syntax format.
[0094] S105: Send each of the md files to the Git repository, and use the Git repository to convert the md files into an initial data dictionary.
[0095] It should be noted that GitLab is an open-source web-based Git repository management tool developed by GitLab Inc. and licensed under the MIT License. It features a wiki and issue tracking functionality, and is a web service built on top of Git, a code management tool. The initial data dictionary is the initial Gitbook, which contains the database table information for each database.
[0096] S106: Compare the initial data dictionary with the historical data dictionary generated last time to obtain a comparison result, and update the initial data dictionary based on the comparison result to obtain a current data dictionary corresponding to each of the databases.
[0097] It should be noted that the information in the current data dictionary is compared with the information in the last generated data dictionary to determine the difference between the two, that is, the comparison result; the comparison result is further refined in the data dictionary, so that technical personnel can directly determine the changes in database table information during the subsequent maintenance process.
[0098] In the method provided by an embodiment of the present invention, database information for multiple databases is obtained. Based on the database information, a shell script corresponding to each database is generated. The database table information of each database is read through the shell script. The data table information of the multiple databases is identified as different md files using the database name. The shell script loops through the database tables of each database. Each md file is sent to a Git repository, which generates an initial data dictionary corresponding to each database. The differences between the two are then determined using a historical data dictionary. The differences are recorded in the data dictionary, updating the initial data dictionary and obtaining the current data dictionary.
[0099] By applying the method provided in the embodiment of the present invention, it is possible to automatically maintain the database table information of the database and record the relevant differences, thereby reducing the difficulty of subsequent work.
[0100] refer to Figure 4 In the method provided by the embodiment of the present invention, generating the md file corresponding to each database based on the database information and the database table information includes:
[0101] S401: Obtain the database name of the database corresponding to each database information contained in the database information, and generate a first-level menu md file corresponding to each database based on each database name.
[0102] Each of the first-level menu md files is used to point to its corresponding database.
[0103] S402: Based on the database table information corresponding to each database, determine each database table included in each database, and generate a secondary menu md file corresponding to each database table.
[0104] It should be noted that the database is a relational database, which uses a relational model to organize data. It stores data in the form of rows and columns to facilitate user understanding. This series of rows and columns of a relational database is called a table, and a group of tables constitutes a database.
[0105] It is understood that the secondary menu md file corresponding to each database table belongs to the first menu md file corresponding to the database to which the database table belongs. That is, the md file to be generated contains multiple first-level menus, each of which corresponds to a database, and each first-level menu contains multiple second-level menus, each of which corresponds to a database table in the database corresponding to the first-level menu to which it belongs.
[0106] S403: Obtain basic table information, table structure information, table index information, and table data example information from each database table information.
[0107] Specifically, for basic table information: the basic table information comes from the git repository. If it is a newly added table, there is no basic information maintenance file in the repository. The program generates the basic table information based on the template file. If there is any modification, modify the basic information file in the git repository, and subsequent scheduled tasks will synchronize the git repository file to update the data dictionary. For table structure information: plsq command pg-cli.sh connects to the database to query the structure information of the data table (field number, field name, field type, field comment, whether it is empty). For table index information: use the plsq command pg-cli.sh to connect to the database to query the index of the data table. For table data sample information: query the corresponding amount of data according to the preset quantity.
[0108] S404: Generate detailed table information corresponding to each database table based on the basic table information, table structure information, table index information and table data example information in each database table information.
[0109] Among them, the table detailed information is equivalent to the third-level menu md file under the second-level menu md file corresponding to each database table information.
[0110] S405: Generate an md file corresponding to each of the databases based on the first-level menu md file, the second-level menu md file and the table detailed information.
[0111] It can be understood that the md file consists of the first-level menu md file, the second-level menu md file and the table detailed information.
[0112] Furthermore, in the embodiment of the present invention, the Git repository converts the md file into a data dictionary format. Figure 5 As shown, Figure 5 This is a display format of the data dictionary provided by an embodiment of the present invention.
[0113] In the method provided by the embodiments of the present invention, a first-level menu .md file is generated based on database information, followed by a second-level menu .md file based on database table information. Finally, table details are generated based on basic table information, table structure information, table index information, and table data sample information, thereby generating an .md file. The table details record detailed data information for each database table. After converting the .md file into a data dictionary, users can access the data dictionary through a web page.
[0114] refer to Figure 6 In the method provided by an embodiment of the present invention, the step of comparing the initial data dictionary with the previously generated historical data dictionary to obtain a comparison result, and updating the initial data dictionary based on the comparison result, includes:
[0115] S601: Based on the information of each database table, determine the current database summary information corresponding to each database, and save the database summary information into the initial data dictionary.
[0116] The database summary information includes the number of database tables and the total amount of database record data.
[0117] S602: Acquire the historical database summary information stored in the historical data dictionary.
[0118] S603: Compare the current database summary information with the historical database summary information to determine difference information between the initial data dictionary and the historical data dictionary.
[0119] Specifically, the difference between the number of database tables in the current database summary information and the number of database tables in the historical database summary information is compared, and the difference between the total amount of database record data in the current database summary information and the total amount of database record data in the historical database summary information is compared to obtain the difference information between the initial data dictionary and the historical data dictionary.
[0120] It should be noted that if the number of database tables and the total amount of database records in the two data dictionaries are relatively consistent, the difference information will be empty.
[0121] S604: Update the difference information to the change record of the initial data dictionary.
[0122] In the method provided by the embodiment of the present invention, by comparing the database summary information, or the specific change content of the database table information, the user can directly query the change record to determine the change status of the database table, which is convenient for specifying the subsequent work plan.
[0123] Optionally, after updating the initial data dictionary to obtain the current data dictionary, the home page description can be recorded in the data dictionary, including: recording the data dictionary update date, database summary information (the number of database tables from multiple data sources, the total amount of database records) and other information descriptions.
[0124] Furthermore, the method of the embodiment of the present invention is deployed through Gitlab CI continuous integration, and the database table information recording method implemented by the embodiment of the present invention is configured through YAML file management. The YAML file records the script content implemented by the database table information recording method provided by the present invention. The file is stored in the root directory of the Git repository and is named by default: .gitlab-ci.yml, which defines how the job should work. Among them, stages: each stage of a pipeline; image: the docker image used; stage: a job stage. The script content in the YAML file is as follows:
[0125]
[0126]
[0127] The above script describes three phases: Create-book (configuration phase), Gitbook-Build (data dictionary generation phase), and Pages. In the Create-book phase, Shell commands are used to configure the initial environment, find all database tables, collect database table details, generate descriptions, identify differences, summarize history, and upload the .md file to Git. GitLab configures a scheduled task to periodically pull files from the Git repository and update the data dictionary. After each stage of the pipeline successfully completes, the Gitbook static site is hosted on the GitLab Pages server.
[0128] In the embodiment of the present invention, after the current data dictionary is generated, the user can access the current data dictionary through a web page.
[0129] The specific implementation processes and derivative methods of the above embodiments are all within the protection scope of the present invention.
[0130] and Figure 1Corresponding to the above method, the embodiment of the present invention further provides a database table information recording device for recording Figure 1 The specific implementation of the method, the database table information recording device provided by the embodiment of the present invention can be applied to a computer terminal or various mobile devices, and its structural diagram is as follows Figure 7 As shown, specifically including:
[0131] An acquisition unit 701 is configured to acquire database information of a plurality of preset databases;
[0132] A first generating unit 702 is configured to generate a Shell script corresponding to each database based on the database information of each database;
[0133] A reading unit 703 is configured to apply the Shell script to read database table information of each of the databases;
[0134] The second generating unit 704 is configured to generate an md file corresponding to each database based on the database information and the database table information;
[0135] The third generating unit 705 is configured to send each of the md files to the Git repository and convert the md files into an initial data dictionary using the Git repository;
[0136] The updating unit 706 is configured to compare the initial data dictionary with the historical data dictionary generated last time to obtain a comparison result, and update the initial data dictionary based on the comparison result to obtain a current data dictionary corresponding to each of the databases.
[0137] In the apparatus provided by an embodiment of the present invention, database information for multiple databases is obtained, and a shell script corresponding to each database is generated based on the database information. The database table information for each database is read using the shell script. The database table information for each database is identified as a separate .md file using the database name, and the shell script loops through the database table for each database. Each .md file is sent to a Git repository, which generates an initial data dictionary corresponding to each database. Differences between the two are then determined using a historical data dictionary, and the differences are recorded in the data dictionary. This updates the initial data dictionary, thereby obtaining the current data dictionary.
[0138] By using the device provided by the embodiment of the present invention, it is possible to automatically maintain the database table information of the database and record the relevant differences, thereby reducing the difficulty of subsequent work.
[0139] In the apparatus provided by the embodiment of the present invention, the acquiring unit 701 includes:
[0140] A receiving subunit, configured to receive user maintenance information uploaded by a user, wherein the user maintenance information includes data update strategy, data classification and data source;
[0141] A monitoring subunit is used to write the user maintenance information into a template file preset in the Git repository and monitor in real time whether the current environment meets the data update strategy;
[0142] The first acquisition subunit is configured to connect to each of the databases and acquire database information of each of the databases if the current environment satisfies the data update strategy.
[0143] In the device provided by the embodiment of the present invention, the reading unit 703 includes:
[0144] a determination subunit, configured to determine a reading order of each of the databases according to a preset sorting rule;
[0145] The reading subunit is used to apply the plsq instruction in the Shell script to sequentially read the database table information of each of the databases according to the reading order.
[0146] In the apparatus provided by the embodiment of the present invention, the second generating unit 704 includes:
[0147] The second acquisition subunit is configured to acquire a database name of a database corresponding to each database information contained in the database information, and generate a first-level menu md file corresponding to each database based on each database name, wherein each first-level menu md file is used to point to its corresponding database;
[0148] A first generating subunit is configured to determine each database table contained in each database based on database table information corresponding to each database, and generate a secondary menu md file corresponding to each database table;
[0149] A third acquisition subunit is configured to acquire basic table information, table structure information, table index information, and table data example information from each of the database table information;
[0150] A second generating subunit is configured to generate detailed table information corresponding to each of the database tables based on the basic table information, table structure information, table index information, and table data example information in each of the database table information;
[0151] The third generating subunit is used to generate an md file corresponding to each of the databases based on the first-level menu md file, the second-level menu md file and the table detailed information.
[0152] In the apparatus provided by the embodiment of the present invention, the updating unit 706 includes:
[0153] a storage unit, configured to determine, based on the information of each database table, current database summary information corresponding to each database, and save the database summary information to the initial data dictionary, wherein the database summary information includes the number of database tables and the total amount of database record data;
[0154] A fourth acquisition subunit is used to acquire the historical database summary information stored in the historical data dictionary;
[0155] a comparing subunit, configured to compare the current database summary information with the historical database summary information to determine difference information between the initial data dictionary and the historical data dictionary;
[0156] The updating subunit is configured to update the difference information to the change record of the initial data dictionary.
[0157] The specific working process of each unit and sub-unit in the database table information recording device disclosed in the above embodiment of the present invention can refer to the corresponding content in the database table information recording method disclosed in the above embodiment of the present invention, and will not be repeated here.
[0158] An embodiment of the present invention further provides a storage medium, which includes stored instructions, wherein when the instructions are executed, the device where the storage medium is located is controlled to execute the above-mentioned database table information recording method.
[0159] The embodiment of the present invention further provides an electronic device, the structural diagram of which is shown in FIG. Figure 8 As shown, the system specifically includes a memory 801 and one or more instructions 802, wherein the one or more instructions 802 are stored in the memory 801 and are configured to be executed by one or more processors 803 to perform the following operations:
[0160] Get database information of multiple preset databases;
[0161] Based on the database information of each database, generating a Shell script corresponding to each database;
[0162] Applying the Shell script to read database table information of each of the databases;
[0163] Generate an md file corresponding to each database based on the database information and the database table information;
[0164] Send each of the md files to the Git repository, and use the Git repository to convert the md files into an initial data dictionary;
[0165] The initial data dictionary is compared with the historical data dictionary generated last time to obtain a comparison result, and the initial data dictionary is updated based on the comparison result to obtain a current data dictionary corresponding to each of the databases.
[0166] Each embodiment in this specification is described in a progressive manner. The same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. In particular, for system or system embodiments, since they are basically similar to method embodiments, the description is relatively simple. For relevant parts, refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. A person of ordinary skill in the art can understand and implement it without expending creative work.
[0167] Those skilled in the art may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein may be implemented by electronic hardware, computer software, or a combination of both.
[0168] To clearly illustrate the interchangeability of hardware and software, the above descriptions have generally described the components and steps of each example by function. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Professionals may use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of the present invention.
[0169] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not limited to the embodiments shown herein but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for recording database table information, characterized in that: include: Receive user maintenance information uploaded by the user, the user maintenance information including data update strategy, data classification and data source; the data update strategy is the time set by the user to record database table information; Write the user maintenance information into the template file preset in the Git repository, and monitor in real time whether the current time point reaches the time set in the data update strategy; If the current time point reaches the time set in the data update strategy, connect to each of the databases to obtain database information of each of the databases; Based on the database information of each database, generating a Shell script corresponding to each database; Applying the Shell script to read database table information of each of the databases; Generate an md file corresponding to each database based on the database information and the database table information; Send each of the md files to the Git repository, and use the Git repository to convert the md files into an initial data dictionary; Based on the information of each database table, determine the current database summary information corresponding to each database, and save the database summary information to the initial data dictionary, wherein the database summary information includes the number of database tables and the total amount of database record data; Get the historical database summary information stored in the historical data dictionary; Comparing the current database summary information with the historical database summary information to determine difference information between the initial data dictionary and the historical data dictionary; The difference information is updated to the change record of the initial data dictionary to obtain the current data dictionary corresponding to each of the databases.
2. The method according to claim 1, characterized in that The application of the Shell script to read the database table information of each database includes: Determining the reading order of each of the databases according to a preset sorting rule; Apply the plsq instruction in the Shell script to read the database table information of each database in sequence according to the reading order.
3. The method according to claim 2, characterized in that The generating of the md file corresponding to each database based on the database information and the database table information includes: Obtaining the database name of the database corresponding to each database information contained in the database information, and generating a first-level menu md file corresponding to each database based on each database name, wherein each first-level menu md file is used to point to its corresponding database; Based on the database table information corresponding to each of the databases, determine each database table contained in each of the databases, and generate a secondary menu md file corresponding to each of the database tables; Obtaining basic table information, table structure information, table index information, and table data example information from each of the database table information; Generate detailed table information corresponding to each database table based on basic table information, table structure information, table index information, and table data example information in each database table information; Based on the first-level menu md file, the second-level menu md file and the table detailed information, an md file corresponding to each of the databases is generated.
4. A database table information recording device, characterized in that: include: An acquisition unit, configured to acquire database information of a plurality of preset databases; A first generating unit, configured to generate a Shell script corresponding to each of the databases based on the database information of each of the databases; A reading unit, configured to apply the Shell script to read database table information of each of the databases; A second generating unit is configured to generate an md file corresponding to each of the databases based on the database information and the database table information; A third generating unit is configured to send each of the md files to a Git repository, and convert the md files into an initial data dictionary using the Git repository; an updating unit, configured to compare the initial data dictionary with a previously generated historical data dictionary to obtain a comparison result, and update the initial data dictionary based on the comparison result to obtain a current data dictionary corresponding to each of the databases; Wherein, the acquisition unit includes: A receiving subunit, configured to receive user maintenance information uploaded by a user, wherein the user maintenance information includes data update strategy, data classification and data source; A monitoring subunit is used to write the user maintenance information into a template file preset in the Git repository and monitor in real time whether the current time reaches the time set in the data update strategy; A first acquisition subunit is configured to connect to each of the databases and acquire database information of each of the databases if the current time point reaches the time set in the data update strategy; The updating unit includes: a storage unit, configured to determine, based on the information of each database table, current database summary information corresponding to each database, and save the database summary information to the initial data dictionary, wherein the database summary information includes the number of database tables and the total amount of database record data; A fourth acquisition subunit is used to acquire the historical database summary information stored in the historical data dictionary; a comparing subunit, configured to compare the current database summary information with the historical database summary information to determine difference information between the initial data dictionary and the historical data dictionary; The updating subunit is configured to update the difference information to the change record of the initial data dictionary, and obtain the current data dictionary corresponding to each of the databases.
5. The device according to claim 4, characterized in that The reading unit includes: a determination subunit, configured to determine a reading order of each of the databases according to a preset sorting rule; The reading subunit is used to apply the plsq instruction in the Shell script to sequentially read the database table information of each of the databases according to the reading order.
6. The device according to claim 5, characterized in that The second generating unit includes: The second acquisition subunit is configured to acquire a database name of a database corresponding to each database information contained in the database information, and generate a first-level menu md file corresponding to each database based on each database name, wherein each first-level menu md file is used to point to its corresponding database; A first generating subunit is configured to determine each database table contained in each database based on database table information corresponding to each database, and generate a secondary menu md file corresponding to each database table; A third acquisition subunit is configured to acquire basic table information, table structure information, table index information, and table data example information from each of the database table information; A second generating subunit is configured to generate detailed table information corresponding to each of the database tables based on the basic table information, table structure information, table index information, and table data example information in each of the database table information; The third generating subunit is used to generate an md file corresponding to each of the databases based on the first-level menu md file, the second-level menu md file and the table detailed information.
Citation Information
Patent Citations
Version difference code file obtaining method and device, computer equipment and medium
CN112947991A