CN110825795A - Method, device and equipment for accessing database and computer readable storage medium - Google Patents

Method, device and equipment for accessing database and computer readable storage medium Download PDF

Info

Publication number
CN110825795A
CN110825795A CN201910882851.6A CN201910882851A CN110825795A CN 110825795 A CN110825795 A CN 110825795A CN 201910882851 A CN201910882851 A CN 201910882851A CN 110825795 A CN110825795 A CN 110825795A
Authority
CN
China
Prior art keywords
database
preset
configuration information
information
script
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201910882851.6A
Other languages
Chinese (zh)
Other versions
CN110825795B (en
Inventor
陈煜佳
骆东方
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201910882851.6A priority Critical patent/CN110825795B/en
Priority to PCT/CN2019/118459 priority patent/WO2021051614A1/en
Publication of CN110825795A publication Critical patent/CN110825795A/en
Application granted granted Critical
Publication of CN110825795B publication Critical patent/CN110825795B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/256Integrating or interfacing systems involving database management systems in federated or virtual databases
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to the field of research and development management, and particularly discloses a method, a device, equipment and a computer readable storage medium for accessing a database, wherein the method comprises the following steps: when a calling instruction is received, acquiring an identification code of a database to be connected through a preset script corresponding to the calling instruction, and acquiring a database type label corresponding to the identification code; loading a connecting tool corresponding to the database type label through a preset script, wherein the preset script comprises at least one connecting tool, and the connecting tool comprises configuration information of a database to be connected; the attribute information of the databases to be connected is read, and the databases to be connected are connected according to the configuration information and the attribute information based on the preset scripts, so that unified management of multiple types of databases is realized, information diversification is avoided, database types are automatically identified, manual judgment links are reduced, error rate is effectively reduced, and database access efficiency is improved.

Description

Method, device and equipment for accessing database and computer readable storage medium
Technical Field
The present invention relates to the field of research and development management, and in particular, to a method, an apparatus, a device, and a computer-readable storage medium for accessing a database.
Background
At present, various types of database software are available on the market, each database has an independent service mode and a client, and the coping scenarios are different. In the process of business development and development of companies, corresponding system development adopts various databases to arrange based on business requirements, but how to rapidly deploy various database scripts to improve the efficiency of data access becomes a challenge in deployment work.
The traditional database deployment mode is that script execution is performed in a corresponding type of database client, if multiple types of databases are associated in a project, deployment personnel need to open the client of each database when deploying the multiple types of databases, and it is necessary to know and keep in mind what type and corresponding client each database is. Because human factors exist in the existing access of the multi-type database, the access efficiency is low, and the database access error is easily caused, thereby causing system failure.
Disclosure of Invention
The invention mainly aims to provide a method, a device and equipment for accessing a database and a computer readable storage medium, aiming at solving the technical problems that the conventional method for accessing a multi-type database has human factors, low access efficiency and is easy to cause database access errors so as to cause system faults.
In a first aspect, the present application provides a method for accessing a database, where the method for accessing a database includes:
when a calling instruction is received, acquiring an identification code of a database to be connected through a preset script corresponding to the calling instruction, and acquiring a database type label corresponding to the identification code;
loading a connecting tool corresponding to the database type label through the preset script, wherein the preset script comprises at least one connecting tool, and the connecting tool comprises configuration information of the database to be connected;
and reading the attribute information of the database to be connected, and connecting the database to be connected according to the configuration information and the attribute information based on the preset script.
In a second aspect, the present application further provides an apparatus for accessing a database, the apparatus for accessing a database comprising:
the acquisition module is used for acquiring an identification code of a database to be connected through a preset script corresponding to a calling instruction when the calling instruction is received, and acquiring a database type label corresponding to the identification code;
the loading module is used for loading a connection tool corresponding to the database type label through the preset script, wherein the preset script comprises at least one connection tool, and the connection tool comprises configuration information of the database to be connected;
and the connection module is used for connecting the database to be connected according to the configuration information and the attribute information based on reading the attribute information of the database to be connected and the preset script.
In a third aspect, the present application further provides a computer device, including: a processor, a memory, and a computer program stored on the memory and executable by the processor, wherein the computer program, when executed by the processor, implements the steps of the method of accessing a database as described in the above invention.
In a fourth aspect, the present application further provides a computer readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of accessing a database as described in the above invention.
The embodiment of the invention provides a method, a device, equipment and a computer readable storage medium for accessing a database, wherein when a calling instruction is received, an identification code of a database to be connected is obtained through a preset script corresponding to the calling instruction, and a database type label corresponding to the identification code is obtained; loading a connecting tool corresponding to the database type label through the preset script, wherein the preset script comprises at least one connecting tool, and the connecting tool comprises configuration information of the database to be connected; the attribute information of the databases to be connected is read, and the databases to be connected are connected according to the configuration information and the attribute information based on the preset scripts, so that unified management of multiple types of applied databases is realized, information diversification is avoided, database types are automatically identified, manual judgment links are reduced, error rate is effectively reduced, and database access efficiency is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic flowchart of a method for accessing a database according to an embodiment of the present application;
FIG. 2 is a flow diagram illustrating sub-steps of the method of accessing a database of FIG. 1;
FIG. 3 is a flow diagram illustrating sub-steps of the method of accessing a database of FIG. 1;
FIG. 4 is a schematic flow chart illustrating another method for accessing a database according to an embodiment of the present application;
FIG. 5 is a schematic block diagram of an apparatus for accessing a database according to an embodiment of the present application;
FIG. 6 is a schematic block diagram of a sub-module of the access database apparatus of FIG. 5;
FIG. 7 is a schematic block diagram of a sub-module of the access database apparatus of FIG. 5;
FIG. 8 is a schematic block diagram of another apparatus for accessing a database provided by an embodiment of the present application;
fig. 9 is a block diagram schematically illustrating a structure of a computer device according to an embodiment of the present application.
The implementation, functional features and advantages of the objectives of the present application will be further explained with reference to the accompanying drawings.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The flow diagrams depicted in the figures are merely illustrative and do not necessarily include all of the elements and operations/steps, nor do they necessarily have to be performed in the order depicted. For example, some operations/steps may be decomposed, combined or partially combined, so that the actual execution sequence may be changed according to the actual situation.
The embodiment of the application provides a method, a device and equipment for accessing a database and a computer readable storage medium. The method for accessing the database can be applied to terminal equipment, and the terminal equipment can be a mobile phone, a tablet computer, a notebook computer and a desktop computer.
Some embodiments of the present application will be described in detail below with reference to the accompanying drawings. The embodiments described below and the features of the embodiments can be combined with each other without conflict.
Referring to fig. 1, fig. 1 is a flowchart illustrating a method for accessing a database according to an embodiment of the present application.
As shown in fig. 1, the method for accessing a database includes steps S100 to S300.
And S100, when a call instruction is received, acquiring an identification code of the database to be connected through a preset script corresponding to the call instruction, and acquiring a database type label corresponding to the identification code.
When the terminal receives a call instruction input by a user, the preset script corresponding to the call instruction is operated, and the preset script detects the identification code of the database to be connected in the operation process. The calling instruction can be Chinese, English or number. And the terminal detects the identification code of the database to be connected through a preset script and acquires the database type label corresponding to the identification code of the data to be connected.
For example, when the terminal acquires the identification code, the identification code is an oracle field, so that the database with an oracle tag corresponding to the identification code is acquired. The preset script is a preset one-key execution tool script which is an execution script of each database and is used for detecting the identification codes of each database, packaging the connection tools of each database, loading the connection tools of the databases, and storing the attribute information of each database, wherein the attribute information comprises the sequence of the proofreading configuration information when the connection databases are loaded.
In an embodiment, specifically referring to fig. 2, step S100 includes: substeps 101 to substep S103.
And a substep S101, when receiving the call instruction, acquiring a preset script corresponding to the call instruction, and running the script to detect the identification code of the data to be connected.
When the terminal receives a call instruction input by a user, the preset script corresponding to the call instruction is operated, and the preset script detects the identification code of the database to be connected in the operation process. For example, when a terminal receives a script name input by a user, a preset script is acquired by indexing the script name, and by presetting the preset script, the script detects an identification code of a database to be connected in the terminal in real time or at regular time in the running process.
And a substep S102, reading the identification code of the database to be connected, calling the preset configuration management library, searching a first association table in the preset configuration management library, and acquiring the corresponding field information of the identification code in the first association table.
And when the terminal detects the identification code of the data to be connected through the preset script, reading the identification code and calling the preset configuration management library. The preset configuration library (cmdb) stores various configuration information which is compatible with all server types and process information of access servers, and meanwhile, the accuracy of data is guaranteed depending on related processes. The information such as the name, the IP, the port, the account password and the like of the database to be connected is stored in a preset configuration library in advance in a form of a table and the like. The terminal searches a first association table in the preset configuration management library, and acquires field information corresponding to the identification code in the first association table, for example, when the acquired identification code is a number 12345, the terminal searches for the field information corresponding to the number 12345 in the first association table.
And a substep S103, converting the field information into a database type label corresponding to the identification code after the field information is obtained.
And after the terminal acquires the field information corresponding to the identification code in the first association table, converting the acquired field information into the database type label corresponding to the data to be connected. For example, when the database identification code read in is acquired as 12345, the terminal reads in the association table that the character information of 1 is the letter m, the character information of 2 is the letter y, the character information of 3 is the letter s, the character information of 4 is the letter q, and the character information of 5 is the letter l, so that the type tag of the database to be connected that can be obtained is mysql.
In one embodiment, when a call instruction in a command prompt box is received, a corresponding unique code of the call instruction in a preset configuration management library is read; searching a second association table, reading the corresponding character meaning of the unique code in the second association table, and converting the character meaning into a script name corresponding to the calling instruction; and detecting the identification code of the database to be connected in real time by running the preset script of the script name.
A terminal receives a call instruction input by a user in a command prompt box (cmd), wherein the cmd is a shell program used for running a Windows control panel program or some DOS programs under Windows NT; or a shell program for running only the control panel program under Windows CE. Reading the unique code corresponding to the calling instruction in a preset configuration management library, searching a second association table in the preset configuration management library, reading the field meaning of the unique code in the second association table, converting the character meaning into a script name corresponding to the calling instruction, and detecting the identification code of the database to be connected in real time by running the preset script of the script name.
And S200, loading a connecting tool corresponding to the database type label through a preset script, wherein the preset script comprises at least one connecting tool, and the connecting tool comprises configuration information of a database to be connected.
When the terminal acquires the type tag of the database to be connected, the connection tool corresponding to the database type tag is loaded through the preset script, for example, when the terminal acquires the mongodb database, the preset script acquires the mongodb database, and loads the connection tool mongo of the mongodb database, and the mongo tool is a client tool of the mongodb database and is used for connecting the mongodb database. When the preset script is loaded to the monogo tool, the terminal acquires configuration information of the monogo tool for connecting with the database to be connected, the monogo tool can be preset, or can be downloaded based on the name of the database to be connected by presetting a key to execute the tool script, for example, when the preset one-key to execute the tool script is acquired to the monogo database, the preset one-key to execute the tool script is matched with the tool name monogo corresponding to the monogo database, the monogo tool is downloaded, or can be preset, and the terminal stores a plurality of client side connection tools in the one-key to execute the tool script.
In one embodiment, a connection tool name corresponding to a database type label is obtained through the database type label; and loading a connection tool corresponding to the name of the connection tool in the preset script, and acquiring the configuration information of the database to be connected in the connection tool.
If the type label of the database to be connected, which is acquired by the terminal, is an oracle database, a preset sql plus tool is loaded through presetting; if the acquired type label of the database to be connected is a mysql database, loading a preset mysql tool through a preset script; if the acquired type label of the database to be connected is a postgresql database, loading a preset psql tool through a preset script; and when the preset sql plus tool, the preset mysql tool or the preset psql tool is loaded, acquiring monitoring configuration information and network configuration information of the preset sql plus tool, the preset mysql tool or the preset psql tool, wherein the configuration information comprises the monitoring configuration information and the network configuration information.
For example, when the terminal acquires that the type tag of the database to be connected is an oracle database, the client sql plus tool matched with the oracle database sends an instruction for loading the sql plus tool to a preset script, and then the preset script loads the stored sql plus tool; if the terminal acquires that the type tag of the database to be connected is the mysql database, the mysql tool is matched with the client of the mysql database, an instruction for loading the mysql tool is sent to a preset script, and the preset script loads the stored mysql tool; and if the terminal acquires that the type label of the database to be connected is the postgresql database, matching the client psql tool of the postgresql database, and sending an instruction for loading the mysql tool to a preset script, and presetting the psql tool for loading and storing.
When a terminal loads an sql plus tool, a mysql tool or a psql tool in a preset script, acquiring monitoring configuration information and network configuration information of a connection oracle database in the sql plus tool, monitoring configuration information and network configuration information of a connection mysql database in the mysql tool or monitoring configuration information and network configuration information of a connection postgresql database in the psql tool, wherein the monitoring configuration information and the network configuration information are database attribute information in a loading configuration page of the connection tool, and are wrong with standard monitoring configuration information and network configuration information of the connection database, and database attribute information in the loading configuration page is also possible to be blank.
And step S300, reading the attribute information of the database to be connected, and connecting the database to be connected according to the configuration information and the attribute information based on a preset script.
And after the terminal acquires the configuration information of the database to be connected, reading the attribute information of the database to be connected, wherein the attribute information of the database to be connected is stored in a preset configuration management library. And when the preset script reads that the attribute information of the database to be connected is consistent with the configuration information of the database to be connected, the terminal is connected with the database to be connected through a connecting tool in the preset script.
Specifically, when the terminal acquires that the type tag of the database to be connected is the tag of the oracle database, a connection tool corresponding to the oracle database is acquired, the monitoring configuration information and the network configuration information are acquired from the connection tool, the attribute information of the oracle database type in the preset configuration management library is read through the type tag of the oracle database, the oracle database type is used as a search condition in the preset configuration management library, and the monitoring configuration information and the network configuration information of the oracle database type are read, wherein the monitoring configuration information and the network configuration information of the oracle database can be stored in the preset configuration management library in a form of a table or in other forms.
For example, when the terminal acquires that the attribute information of the oracle database type tag in the preset configuration management library is: port/databasename, wherein when sqlplus is sqlplus tool name, passcode is password, hostep is server IP address, port is port information and databasename, sql plus tool name, server IP, port data value and databank name of oracle database are obtained.
Specifically, when the terminal acquires the type tag of the database to be connected, a connection tool corresponding to the postgresql database is acquired, the monitoring configuration information and the network configuration information are acquired from the connection tool, and the attribute information of the postgresql database type in the preset configuration management library is read through the postgresql database type. For example, when the terminal acquires that the attribute information of the postgresql database type in the preset configuration management library is: and acquiring the psql tool name, the server IP, the port data value and the database name of the postgresql database when the psql is the psql tool name, the hosip is the server IP address, the port is the port information, the user is the user name and the database name.
Specifically, when the terminal acquires the type tag of the database to be connected, a connection tool corresponding to the mysql database is acquired, the monitoring configuration information and the network configuration information are acquired from the connection tool, the attribute information of the mysql database type in the preset configuration management library is read through the mysql database type, for example, when the terminal acquires the attribute information of the mysql database type in the preset configuration management library, the attribute information is as follows: and acquiring the mysql tool name, the server IP, the port data value, the database name and the password of the mysql database when the mysql is the mysql tool name, the hostep is the server IP address, the port is the port information, the user is the user name, the databasename is the database name and the password is the password.
In an embodiment, specifically referring to fig. 3, step S300 includes: substeps 301 to substep S303.
And a substep S301 of judging whether the configuration information is the same as the attribute information through a preset script.
When the terminal obtains attribute information of a type label of data to be connected in a preset configuration management library and configuration information of a database to be connected in a connecting tool, whether the attribute information of the type label of the data to be connected in the preset configuration management library is the same as configuration information of the database to be connected in the connecting tool or not is judged through a preset script, the specific attribute information of the type label of the data to be connected in the preset configuration management library comprises a tool name, a server IP address, port information, a user name, a database name, a password and the like, the configuration information of the database to be connected in the connecting tool comprises monitoring configuration information and network configuration information, wherein the monitoring configuration information comprises the tool name, the user name, the database name and the password, and the network configuration information comprises the server IP address and the port information. The terminal judges whether the name of a connecting tool, the name of a user, the name of a database, a password in the attribute information are the same as the name of a tool for monitoring the configuration information, the name of the user, the name of the database and the password in the attribute information, and whether the IP address and the port information of a server in the attribute information are the same as the IP address and the port information of a network configuration information server in the attribute information.
And a substep S302, if the configuration information is judged to be the same as the attribute information, connecting the databases to be connected through a connection tool.
If the terminal judges that the name, the user name, the database name and the password of the connection tool in the attribute information are the same as the name, the user name, the database name and the password of the tool for monitoring the configuration information in the connection tool and the IP address and the port information of the server in the attribute information are the same as the IP address and the port information of the network configuration information server in the connection tool through the preset script, the terminal is connected with the database to be connected through the connection tool.
And a substep S303, if the configuration information is different from the attribute information, modifying the configuration information according to the attribute information so that the configuration information is the same as the attribute information.
If the terminal judges that the tool name, the user name, the database name, the password in the attribute information are different from the tool name, the user name, the database name and the password in the monitoring configuration information and/or the server IP address and the port information in the attribute information are different from the server IP address and the port information in the network configuration information through the preset script, the terminal modifies the tool name, the user name, the database name and the password in the configuration information and the server IP address and the port information of the network configuration information based on the tool name, the server IP address, the port information, the database name and the password in the attribute information so as to enable the tool name, the server IP address, the port information, the user name, the database name and the password in the attribute information, the tool name, the user name, the database name, the password in the configuration information, the tool name, the user name, the database name, the port information, the, The password is consistent with the server IP address and the port information of the network configuration information, and the server IP address and the port information are connected with the database to be connected through a connecting tool in the preset script.
The method specifically comprises the following steps: if the configuration information is different from the attribute information, acquiring a mapping relation table corresponding to the type label and the attribute value of each attribute from the attribute information; and modifying the attribute values of the tags of the same type in the configuration information based on the mapping relation table, so that the attribute values of the tags of the same type in the configuration information are consistent with the attribute values of the tags of the same type in the attribute information.
When the terminal judges that the tool name, the server IP address, the port information, the user name, the database name and the password in the attribute information are inconsistent with the server IP address and the port information of the network configuration information through a preset script, a mapping relation table of a tool name type label, a server IP address type label, a port information type label, a user name type label, a database name type label and a password type label in the configuration information, a connection tool name type label, a user name type label, a database name type label and a password type label of the configuration information, a server IP address type label and a port information type label of the network configuration information is obtained from the attribute information. The mapping relation table is a category name such as a connection tool name type label, a server IP address type label, a port information type label and a user name type label. And modifying the name of the connection tool, the name of the user and the name of the database in the monitoring configuration information to be consistent with the name of the connection tool, the name of the user and the name of the database in the attribute information through the mapping relation table, modifying the IP and the port information of the server in the network configuration information to be consistent with the IP and the port information of the server in the attribute information, and connecting the database to be connected through the connection tool in the preset script.
In this embodiment, when the terminal receives a call instruction, the terminal detects an identification code of data to be connected through a preset script corresponding to the call instruction, acquires a database type tag of the identification code, loads a connection tool corresponding to the database type tag through the preset script, acquires configuration information of a database to be connected in the connection tool, reads attribute information of the database to be connected, and connects the database to be connected according to the configuration information and the attribute information, so that information diversification is avoided, the function of automatically identifying the database type is realized, manual judgment links are reduced, the error rate is effectively reduced, and the execution efficiency is greatly improved.
Referring to fig. 4, fig. 4 is a schematic block diagram of another method for accessing a database according to an embodiment of the present application.
As shown in fig. 4, the method of accessing a database includes steps S400 to S500.
And S500, when the database to be connected is connected, detecting whether the characters in the interactive window are preset characters or not through a preset script.
And when the terminal is to be connected with the database through the preset script, detecting whether the characters in the interactive window are preset characters or not through the preset script. For example, when the database to be connected is an oracle database, a mysql database or a postgresql database, jumping out an interactive window, acquiring characters in the interactive window, and detecting whether the characters are preset characters through a preset script. It should be noted that the preset characters are set based on actual situations, and this is not specifically limited in this application.
And step S600, if the character in the interactive window is detected to be a preset character, judging that the connection is successful.
And if the preset script is used for connecting the database to be connected and the character of the interactive window is the preset character, judging that the database to be connected is successfully connected. For example, when the terminal is connected with the oracle database through the preset script and the interactive window of the oracle database is obtained as the SQL field, it is determined that the preset one-key execution tool is successfully connected with the oracle database; when the terminal is connected with the mysql database through the preset one-key execution tool and the interactive window of the mysql database is the mysql field, judging that the preset one-key execution tool is successfully connected with the mysql database; when the terminal is connected with the postgresql database through the preset one-key execution tool and the interactive window of the postgresql database is the databasename field, judging that the preset one-key execution tool is successfully connected with the postgresql database.
The method for accessing the database provided by the embodiment can timely end the connection operation of the database when the database is successfully connected by monitoring the connection condition of the database.
Referring to fig. 5, fig. 5 is a schematic block diagram of another apparatus for accessing a database according to an embodiment of the present application.
As shown in fig. 5, the access database apparatus 400 includes: an acquisition module 401, a loading module 402, and a connection module 403.
The obtaining module 401 is configured to, when receiving a call instruction, obtain an identification code of a database to be connected through a preset script corresponding to the call instruction, and obtain a database type tag corresponding to the identification code;
the loading module 402 is configured to load a connection tool corresponding to the database type tag through a preset script, where the preset script includes at least one connection tool, and the connection tool includes configuration information of a database to be connected;
and the connection module 403 is configured to connect the database to be connected according to the configuration information and the attribute information based on reading the attribute information of the database to be connected and based on a preset script.
In one embodiment, as shown in fig. 6, the obtaining module 401 includes:
the first obtaining sub-module 4011 is configured to, when receiving a call instruction, obtain a preset script corresponding to the call instruction, and run the script to detect an identification code of the data to be connected;
the second obtaining sub-module 4012 is configured to read an identification code of the database to be connected, invoke a preset configuration management library, search a first association table in the preset configuration management library, and obtain field information corresponding to the identification code in the first association table;
the converting sub-module 4013 is configured to, after the field information is obtained, convert the field information into a database type tag corresponding to the identification code.
In one embodiment, as shown in fig. 7, the connection module 403 includes:
the judgment sub-module 4031 is used for judging whether the configuration information is the same as the attribute information through a preset script;
the first determination submodule 4032 is used for connecting the database to be connected through the connection tool if the configuration information is determined to be the same as the attribute information;
the second determining sub-module 4033 is configured to modify the configuration information according to the attribute information if it is determined that the configuration information is different from the attribute information, so that the configuration information is the same as the attribute information.
Referring to fig. 8, fig. 8 is a schematic block diagram of another apparatus for accessing a database according to an embodiment of the present application.
As shown in fig. 8, the access database apparatus 500 includes: the device comprises an acquisition module 501, a loading module 502, a connection module 503, a judgment module 504 and a judgment module 505.
The obtaining module 501 is configured to, when receiving a call instruction, obtain an identification code of a database to be connected through a preset script corresponding to the call instruction, and obtain a database type tag corresponding to the identification code;
the loading module 502 is configured to load a connection tool corresponding to the database type tag through a preset script, where the connection tool includes configuration information of a database to be connected;
the connection module 503 is configured to connect the database to be connected according to the configuration information and the attribute information based on reading the attribute information of the database to be connected and based on a preset script;
the judging module 504 is configured to, when the database to be connected is connected, judge whether the connection of the database to be connected is successful;
the determining module 505 is configured to determine that the connection is successful if the interactive window is a preset character when the to-be-connected database is connected and the acquired interactive window is the preset character.
It should be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the apparatus and the modules and units described above may refer to the corresponding processes in the foregoing embodiment of the composite speech recognition method, and are not described herein again.
The apparatus provided by the above embodiments may be implemented in the form of a computer program, which can be run on a computer device as shown in fig. 9.
Referring to fig. 9, fig. 9 is a schematic block diagram of a computer device according to an embodiment of the present disclosure. The computer device may be a terminal.
As shown in fig. 9, the computer device includes a processor, a memory, and a network interface connected by a system bus, wherein the memory may include a nonvolatile storage medium and an internal memory.
The non-volatile storage medium may store an operating system and a computer program. The computer program includes program instructions that, when executed, cause a processor to perform any of the methods for accessing a database.
The processor is used for providing calculation and control capability and supporting the operation of the whole computer equipment.
The internal memory provides an environment for the execution of a computer program on a non-volatile storage medium, which when executed by a processor causes the processor to perform any of a variety of methods for accessing a database.
The network interface is used for network communication, such as sending assigned tasks and the like. Those skilled in the art will appreciate that the configuration shown in fig. 9 is a block diagram of only a portion of the configuration associated with the present application and does not constitute a limitation of the computing device to which the present application is applied, and in particular that the computing device may include more or less components than those shown, or combine certain components, or have a different arrangement of components.
It should be understood that the Processor may be a Central Processing Unit (CPU), and the Processor may be other general purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Wherein a general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Wherein, in one embodiment, the processor is configured to execute a computer program stored in the memory to implement the steps of:
when a calling instruction is received, acquiring an identification code of a database to be connected through a preset script corresponding to the calling instruction, and acquiring a database type label corresponding to the identification code;
loading a connecting tool corresponding to the database type label through a preset script, wherein the preset script comprises at least one connecting tool, and the connecting tool comprises configuration information of a database to be connected;
and reading the attribute information of the database to be connected, and connecting the database to be connected according to the configuration information and the attribute information based on the preset script.
In one embodiment, the processor, when implemented, is configured to implement:
acquiring a connecting tool name corresponding to the database type label through the database type label;
and loading a connection tool corresponding to the name of the connection tool in the preset script, and acquiring the configuration information of the database to be connected in the connection tool.
In one embodiment, the processor, when implemented, is configured to implement:
judging whether the configuration information is the same as the attribute information or not through a preset script;
if the configuration information is the same as the attribute information, connecting the database to be connected through a connecting tool;
and if the configuration information is different from the attribute information, modifying the configuration information according to the attribute information to ensure that the configuration information is the same as the attribute information.
In one embodiment, the processor, when implemented, is configured to implement:
if the configuration information is different from the attribute information, acquiring a mapping relation table corresponding to the type label and the attribute value of each attribute from the attribute information;
and modifying the attribute values of the tags of the same type in the configuration information based on the mapping relation table, so that the attribute values of the tags of the same type in the configuration information are consistent with the attribute values of the tags of the same type in the attribute information.
Wherein in another embodiment the processor is adapted to run a computer program stored in the memory to implement the steps of:
when a database to be connected is connected, detecting whether the characters in the interactive window are preset characters or not through the preset script;
and if the character in the interactive window is detected to be a preset character, judging that the connection is successful.
In one embodiment, the processor, when implemented, is configured to implement:
when a calling instruction is received, acquiring a preset script corresponding to the calling instruction, and running the script to detect an identification code of data to be connected;
reading an identification code of a database to be connected, calling a preset configuration management library, searching a first association table in the preset configuration management library, and acquiring field information corresponding to the identification code in the first association table;
and after the field information is acquired, converting the field information into a database type label corresponding to the identification code.
In one embodiment, the processor, when implemented, is configured to implement:
when a calling instruction in a command prompt box is received, reading a unique code corresponding to the calling instruction in a preset configuration management library;
searching a second association table, reading the character meaning corresponding to the unique code in the second association table, and converting the character meaning into a script name corresponding to the calling instruction;
and detecting the identification code of the database to be connected in real time by running a preset script corresponding to the script name.
Embodiments of the present application also provide a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, where the computer program includes program instructions, and when the program instructions are executed, an implementation method may refer to various embodiments of a method for accessing a database of the present application.
The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiment, for example, a hard disk or a memory of the computer device. The computer readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like provided on the computer device.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A method of accessing a database, comprising:
when a calling instruction is received, acquiring an identification code of a database to be connected through a preset script corresponding to the calling instruction, and acquiring a database type label corresponding to the identification code;
loading a connecting tool corresponding to the database type label through the preset script, wherein the preset script comprises at least one connecting tool, and the connecting tool comprises configuration information of the database to be connected;
and reading the attribute information of the database to be connected, and connecting the database to be connected according to the configuration information and the attribute information based on the preset script.
2. The method for accessing a database according to claim 1, wherein the loading a connection tool corresponding to the database type tag through the preset script, wherein the connection tool including the configuration information of the database to be connected includes:
acquiring a connecting tool name corresponding to the database type label through the database type label;
and loading the connection tool corresponding to the connection tool name in the preset script, and acquiring the configuration information of the database to be connected in the connection tool.
3. The method for accessing database according to claim 2, wherein the connecting the database to be connected according to the configuration information and the attribute information based on the preset script comprises:
judging whether the configuration information is the same as the attribute information or not through the preset script;
if the configuration information is the same as the attribute information, connecting the database to be connected through the connecting tool;
and if the configuration information is different from the attribute information, modifying the configuration information according to the attribute information to ensure that the configuration information is the same as the attribute information.
4. The method according to claim 3, wherein if it is determined that the configuration information is different from the attribute information, modifying the configuration information according to the attribute information so that the configuration information is the same as the attribute information comprises:
if the configuration information is different from the attribute information, acquiring a mapping relation table corresponding to the type label and the attribute value of each attribute from the attribute information;
and modifying the attribute values of the tags of the same type in the configuration information based on the mapping relation table, so that the attribute values of the tags of the same type in the configuration information are consistent with the attribute values of the tags of the same type in the attribute information.
5. The method for accessing database according to any one of claims 1-4, wherein after connecting the database to be connected according to the configuration information and the attribute information based on the preset script, the method further comprises:
when the database to be connected is connected, detecting whether the characters in the interactive window are preset characters or not through the preset script;
and if the character in the interactive window is detected to be a preset character, judging that the connection is successful.
6. The method for accessing a database according to claim 1, wherein the obtaining, when receiving a call instruction, an identification code of a database to be connected through a preset script corresponding to the call instruction, and obtaining a database type tag corresponding to the identification code comprises:
when a call instruction is received, acquiring a preset script corresponding to the call instruction, and running the script to detect the identification code of the data to be connected;
reading the identification code of the database to be connected, calling a preset configuration management library, searching a first association table in the preset configuration management library, and acquiring the corresponding field information of the identification code in the first association table;
and after the field information is acquired, converting the field information into a database type label corresponding to the identification code.
7. The method for accessing a database according to claim 6, wherein the step of obtaining a preset script corresponding to a call instruction when receiving the call instruction, and running the script to detect the identification code of the data to be connected comprises:
when a calling instruction in a command prompt box is received, reading a unique code corresponding to the calling instruction in a preset configuration management library;
searching a second association table, reading the character meaning corresponding to the unique code in the second association table, and converting the character meaning into a script name corresponding to the calling instruction;
and detecting the identification code of the database to be connected in real time by operating the preset script corresponding to the script name.
8. An access database apparatus, characterized in that the access database apparatus comprises:
the acquisition module is used for acquiring an identification code of a database to be connected through a preset script corresponding to a calling instruction when the calling instruction is received, and acquiring a database type label corresponding to the identification code;
the loading module is used for loading a connection tool corresponding to the database type label through the preset script, wherein the preset script comprises at least one connection tool, and the connection tool comprises configuration information of the database to be connected;
and the connection module is used for connecting the database to be connected according to the configuration information and the attribute information based on reading the attribute information of the database to be connected and the preset script.
9. A computer arrangement comprising a processor, a memory, and a computer program stored on the memory and executable by the processor, wherein the computer program, when executed by the processor, carries out the steps of the method of accessing a database of any of claims 1 to 7.
10. A computer-readable storage medium, having a computer program stored thereon, wherein the computer program, when executed by a processor, performs the steps of accessing a database as claimed in any one of claims 1 to 7.
CN201910882851.6A 2019-09-18 2019-09-18 Method, apparatus, device and computer readable storage medium for accessing database Active CN110825795B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201910882851.6A CN110825795B (en) 2019-09-18 2019-09-18 Method, apparatus, device and computer readable storage medium for accessing database
PCT/CN2019/118459 WO2021051614A1 (en) 2019-09-18 2019-11-14 Method, apparatus and device for accessing database, and computer-readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910882851.6A CN110825795B (en) 2019-09-18 2019-09-18 Method, apparatus, device and computer readable storage medium for accessing database

Publications (2)

Publication Number Publication Date
CN110825795A true CN110825795A (en) 2020-02-21
CN110825795B CN110825795B (en) 2023-10-13

Family

ID=69548034

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910882851.6A Active CN110825795B (en) 2019-09-18 2019-09-18 Method, apparatus, device and computer readable storage medium for accessing database

Country Status (2)

Country Link
CN (1) CN110825795B (en)
WO (1) WO2021051614A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113704825A (en) * 2021-09-08 2021-11-26 上海观安信息技术股份有限公司 Database auditing method, device and system and computer storage medium

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2011023959A1 (en) * 2009-08-29 2011-03-03 Datanovation Ltd Database access
CN105760174A (en) * 2016-03-09 2016-07-13 浪潮软件集团有限公司 Suggested data extraction method based on Windows timed task
US20160224667A1 (en) * 2015-02-04 2016-08-04 Xinyu Xingbang Information Industry Co., Ltd. Method and system of implementing an integrated interface supporting operation in multi-type databases
CN107122365A (en) * 2016-02-25 2017-09-01 阿里巴巴集团控股有限公司 The access method and device of heterogeneous database
CN107766526A (en) * 2017-10-26 2018-03-06 中国人民银行清算总中心 Data bank access method, apparatus and system
CN108093094A (en) * 2017-12-08 2018-05-29 腾讯科技(深圳)有限公司 Database instance access method, device, system, storage medium and equipment
US20180322163A1 (en) * 2017-05-05 2018-11-08 Servicenow, Inc. Configuration management identification rule testing
CN108804618A (en) * 2018-05-31 2018-11-13 康键信息技术(深圳)有限公司 Configuration method for database, device, computer equipment and storage medium
CN109325066A (en) * 2018-08-02 2019-02-12 平安科技(深圳)有限公司 A kind of database switching method and terminal device
CN110175206A (en) * 2019-05-24 2019-08-27 江西尚通科技发展股份有限公司 Intellectual analysis operational approach, system and medium for multiple database separation

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102135990A (en) * 2011-03-11 2011-07-27 北京神舟航天软件技术有限公司 Java server page (JSP) template-based intelligent table system capable of being defined freely and generating method
CN106250485A (en) * 2016-07-29 2016-12-21 北京北信源软件股份有限公司 Database upgrade method, Apparatus and system

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2011023959A1 (en) * 2009-08-29 2011-03-03 Datanovation Ltd Database access
US20160224667A1 (en) * 2015-02-04 2016-08-04 Xinyu Xingbang Information Industry Co., Ltd. Method and system of implementing an integrated interface supporting operation in multi-type databases
CN107122365A (en) * 2016-02-25 2017-09-01 阿里巴巴集团控股有限公司 The access method and device of heterogeneous database
CN105760174A (en) * 2016-03-09 2016-07-13 浪潮软件集团有限公司 Suggested data extraction method based on Windows timed task
US20180322163A1 (en) * 2017-05-05 2018-11-08 Servicenow, Inc. Configuration management identification rule testing
CN107766526A (en) * 2017-10-26 2018-03-06 中国人民银行清算总中心 Data bank access method, apparatus and system
CN108093094A (en) * 2017-12-08 2018-05-29 腾讯科技(深圳)有限公司 Database instance access method, device, system, storage medium and equipment
CN108804618A (en) * 2018-05-31 2018-11-13 康键信息技术(深圳)有限公司 Configuration method for database, device, computer equipment and storage medium
CN109325066A (en) * 2018-08-02 2019-02-12 平安科技(深圳)有限公司 A kind of database switching method and terminal device
CN110175206A (en) * 2019-05-24 2019-08-27 江西尚通科技发展股份有限公司 Intellectual analysis operational approach, system and medium for multiple database separation

Also Published As

Publication number Publication date
CN110825795B (en) 2023-10-13
WO2021051614A1 (en) 2021-03-25

Similar Documents

Publication Publication Date Title
CN108427705B (en) Electronic device, distributed system log query method and storage medium
CN110334144B (en) Message display method, device, computer equipment and storage medium
CN110764942A (en) Multi-type data checking method, device, computer system and readable storage medium
CN108427731B (en) Page code processing method and device, terminal equipment and medium
CN110704521A (en) Interface data access method and system
CN112183782B (en) Fault work order processing method and equipment
CN110866258B (en) Rapid vulnerability positioning method, electronic device and storage medium
CN102479138A (en) System and method for detecting error by utilizing image
CN108460271B (en) Terminal identification method and device
CN110837429A (en) Intelligent repairing method and device for online codes of web terminal
CN114218110A (en) Account checking test method and device for financial data, computer equipment and storage medium
CN110688305B (en) Test environment synchronization method, device, medium and electronic equipment
CN110825795A (en) Method, device and equipment for accessing database and computer readable storage medium
CN110764746B (en) Script generation method and device and computer readable storage medium
CN112699027A (en) Interface testing method, device, equipment and readable storage medium
CN110866007B (en) Information management method, system and computer equipment for big data application and table
CN117033249A (en) Test case generation method and device, computer equipment and storage medium
CN112363814A (en) Task scheduling method and device, computer equipment and storage medium
CN109828752B (en) Project code automatic generation method, device, computer equipment and storage medium
CN110337017B (en) Television and log processing method thereof, log processing device and readable storage medium
CN112417012A (en) Data processing method and system
CN109560964B (en) Equipment compliance checking method and device
CN113378180A (en) Vulnerability detection method and device, computer equipment and readable storage medium
CN111562907A (en) Conversion method and system of user-defined interface data
CN110737707A (en) Multi-system log searching method and device and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant