CN107451201B - Data access method and equipment - Google Patents

Data access method and equipment Download PDF

Info

Publication number
CN107451201B
CN107451201B CN201710548153.3A CN201710548153A CN107451201B CN 107451201 B CN107451201 B CN 107451201B CN 201710548153 A CN201710548153 A CN 201710548153A CN 107451201 B CN107451201 B CN 107451201B
Authority
CN
China
Prior art keywords
database
sql
statement
access
database table
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.)
Active
Application number
CN201710548153.3A
Other languages
Chinese (zh)
Other versions
CN107451201A (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.)
Union Mobile Pay Co Ltd
Original Assignee
Union Mobile Pay 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 Union Mobile Pay Co Ltd filed Critical Union Mobile Pay Co Ltd
Priority to CN201710548153.3A priority Critical patent/CN107451201B/en
Publication of CN107451201A publication Critical patent/CN107451201A/en
Application granted granted Critical
Publication of CN107451201B publication Critical patent/CN107451201B/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/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • G06F16/2448Query languages for particular applications; for extensibility, e.g. user defined types
    • 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/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • G06F16/2445Data retrieval commands; View definitions
    • 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/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G06F16/278Data partitioning, e.g. horizontal or vertical partitioning
    • 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/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases

Landscapes

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

Abstract

The invention discloses a data access method and equipment, wherein the method comprises the following steps: obtaining a database access request, wherein the database access request comprises an sql, a fragment field and a data request parameter, and the sql at least maps sql statements of two databases of different types; determining at least two database tables needing to be accessed according to the fragment field and the sqlid, wherein the at least two database tables belong to different types of databases; determining an sql statement for operating the at least two database tables from the sql statement mapped by the sql; and after the statement parameters in the data request parameters and the sql statements are grouped, the at least two database tables are accessed to obtain access results, so that the technical problem that fragmented data access cannot be performed on different types of databases in the prior art can be effectively solved, and the beneficial effect of fragmented data access on different types of databases is realized.

Description

Data access method and equipment
Technical Field
The present invention relates to the field of electronic technologies, and in particular, to a data access method and device.
Background
With the development of internet services, the traffic volume of trading systems has increased exponentially. Meanwhile, the internet service often carries out sales promotion activities, which can lead to the rapid increase of the transaction amount in a certain time period and the occurrence of transaction peak. Transaction systems currently rely on databases as a means of data persistence, and database operations can become a bottleneck in the event of a transaction peak.
Therefore, the scheme of the distributed database is commonly used by internet companies, and a table of the database is horizontally split into a plurality of tables of a plurality of databases, so as to reduce the processing load of each fragment table and improve the access efficiency of the database as a whole, which requires that fragment routing rules are formulated to realize data access under a distributed architecture.
The existing data fragmentation routing scheme is mainly a mode of using a routing table, a structured routing table storage structure is difficult to meet complex routing rule setting, a routing result cannot be obtained from one piece of routing configuration data, multiple pieces of rule data are required to be obtained for secondary operation, and fragmentation data access to different types of databases is not supported.
Therefore, the prior art has the technical problem that fragmented data access cannot be carried out on different types of databases.
Disclosure of Invention
The embodiment of the invention provides a data access method and equipment, which are used for solving the technical problem that fragmentation data access cannot be performed on different types of databases in the prior art.
The embodiment of the invention provides the following specific technical scheme:
obtaining a database access request, wherein the database access request comprises an sql, a fragment field and a data request parameter, and the sql at least maps sql statements of two databases;
determining at least two database tables needing to be accessed according to the fragment field and the sqlid, wherein the at least two database tables belong to different types of databases;
determining an sql statement for operating the at least two database tables from the sql statement mapped by the sql;
and combining statement parameters in the data request parameters with the sql statements and then accessing the at least two database tables to obtain access results.
Optionally, when the sql statement at least maps sql statements of two different types of databases, the sql statements and the sql statements are in a one-to-many correspondence relationship.
Optionally, each sql statement corresponding to the sql is a single table operation for the database or a multi-table association operation for the database.
Optionally, the determining that the database a needs to be accessed according to the fragment field and the sql id specifically includes:
inputting the fragment field and the sqlid as parameters into a preset third-party program for routing calculation to obtain a routing result;
and determining at least two database tables needing to be accessed according to the routing result.
Optionally, when the at least two database tables include a first database table and a second database table, after determining that the at least two database tables need to be accessed according to the fragmentation field and the sqlid, the method includes:
and determining that the database type of the first database table is B, and determining that the database type of the second database table is C, wherein the database type B is different from the database type C.
Optionally, the determining the sql statement that operates the at least two database tables from the sql statement mapped by the sql, specifically includes:
determining an sql statement M corresponding to a database type B from the sql statements mapped by the sql, as an sql statement for operating the first database table;
and determining an sql statement K corresponding to the database type C from the sql statements mapped by the sql as an sql statement for operating the second database table.
Optionally, the routing result further includes database addresses and physical table names of the first database table and the second database table, and the at least two databases are accessed after the statement parameter in the data request parameter is grouped with the sql statement to obtain an access result, specifically:
combining the statement parameter, the sql statement M, the database address of the first database table and the physical table name of the first database table, and then accessing the first database table to obtain an access result;
and combining the statement parameters, the sql statement K, the database address of the second database table and the physical table name of the second database table, and then accessing the second database table to obtain an access result.
Optionally, the number of bytes of the sqlid is less than or equal to 10 bytes.
In a second aspect, an embodiment of the present invention provides a data access device, including:
an access control module: the method comprises the steps of obtaining a database access request, wherein the database access request comprises an sql, a fragment field and a data request parameter, and the sql maps at least sql statements of two databases of different types;
a fragment routing module: the system comprises a data processing module, a fragment field generation module, a database management module and a database management module, wherein the fragment field generation module is used for generating a fragment field according to the fragment field and the sqlid;
the access control module is further configured to: determining an sql statement for operating the at least two database tables from the sql statement mapped by the sql, and accessing the at least two database tables after combining statement parameters in the data request parameters with the sql statement to obtain an access result.
Optionally, when the sql statements of at least two databases are mapped by the sql statements, the sql statements and the sql statements are in a one-to-many correspondence relationship.
Optionally, each sql statement corresponding to the sql is a single table operation for the database or a multi-table association operation for the database.
Optionally, the fragment routing module is specifically configured to:
inputting the fragment field and the sqlid as parameters into a preset third-party program for routing calculation to obtain a routing result;
and determining at least two database tables needing to be accessed according to the routing result.
Optionally, when the at least two database tables include a first database table and a second database table, the access control module is specifically configured to:
and determining that the database type of the first database table is B, and determining that the database type of the second database table is C, wherein the database type B is different from the database type C.
Optionally, the access control module is specifically configured to:
determining an sql statement M corresponding to a database type B from the sql statements mapped by the sql, as an sql statement for operating the first database table;
and determining an sql statement K corresponding to the database type C from the sql statements mapped by the sql as an sql statement for operating the second database table.
Optionally, the routing result further includes database addresses and physical table names of the first database table and the second database table, and the access control module is specifically configured to:
combining the statement parameter, the sql statement M, the database address of the first database table and the physical table name of the first database table, and then accessing the first database table to obtain an access result;
and combining the statement parameters, the sql statement K, the database address of the second database table and the physical table name of the second database table, and then accessing the second database table to obtain an access result.
Optionally, the number of bytes of the sqlid is less than or equal to 10 bytes.
Based on the technical scheme, the embodiment of the invention adopts the method of obtaining the database access request, wherein the database access request comprises an sql, a fragment field and a data request parameter, and the sql maps at least sql statements of two databases of different types; determining at least two database tables needing to be accessed according to the fragment field and the sqlid, wherein the at least two database tables belong to different types of databases; determining an sql statement for operating the at least two database tables from the sql statement mapped by the sql; the statement parameters in the data request parameters and the sql statements are grouped and then the at least two database tables are accessed to obtain an access result, that is, in the embodiment of the present invention, the request parameters sql of the data access correspond to the sql execution statements of the different types of databases, and after the database tables which are required to be accessed and belong to the different types of databases are determined, the sql execution statements of the different types of databases corresponding to the sql statements are input into the corresponding database tables for execution, so that the technical problem that the fragmented data access cannot be performed on the different types of databases in the prior art can be effectively solved, and the technical effect of the fragmented data access on the different types of databases can be realized.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention.
Fig. 1 is a flowchart of a data access method according to an embodiment of the present invention;
fig. 2 is a flowchart of a specific implementation manner of step S102 in the data access method according to the embodiment of the present invention;
fig. 3 is a flowchart of a specific implementation manner of step S103 in the data access method according to the embodiment of the present invention;
fig. 4 is a schematic structural diagram of a data access device according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of another data access device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the technical solutions of the present invention. All other embodiments obtained by a person skilled in the art without any creative effort based on the embodiments described in the present document belong to the protection scope of the technical solution of the present invention.
In the embodiment of the present invention, as shown in fig. 1, the data access process is as follows:
step S101: obtaining a database access request, wherein the database access request comprises an sql, a fragment field and a data request parameter, and the sql at least maps sql statements of two databases of different types;
step S102: determining at least two database tables needing to be accessed according to the fragment field and the sqlid, wherein the at least two database tables belong to different types of databases;
step S103: determining an sql statement for operating the at least two database tables from the sql statement mapped by the sql;
step S104: and combining statement parameters in the data request parameters with the sql statements and then accessing the at least two database tables to obtain access results.
In a specific implementation process, the database access subsystem first executes the step S101, that is, obtains a database access request, where the database access request includes an sql, a fragmentation field, and a data request parameter, and the sql maps at least sql statements of two different types of databases.
In practical applications, when a database access is required, the database access subsystem receives a database access request sent by an application system, where the database access request includes an sql, a fragmentation field, and a data request parameter.
In the embodiment of the present invention, the sql statement that the sql maps at least two different types of databases is defined, and the sql statement of the database are in a one-to-many correspondence relationship, that is, each sql corresponds to at least two sql statements, for example, when the sql maps the sql statements of two different types of databases, the sql can be defined to respectively correspond to the sql statement of the database a with the database type Db2 and the sql statement of the database B with the database type Mysql; when the sql is mapped to sql statements of three different types of databases, the sql statements corresponding to the database a with the database type Db2, the sql statements corresponding to the database B with the database type Mysql, the sql statements corresponding to the database C with the database type Oracle, and the like can be defined, which are not listed here.
In the embodiment of the present invention, specifically, for example, the sql statements of the database a, the database B, and the database C, which are respectively mapped by the sql, are specifically defined, the sql statements of the database a, which are respectively corresponding to the database type Db2, the sql statements of the database B, which are corresponding to the database type Mysql, and the sql statements of the database C, which are corresponding to the database type Oracle, are respectively defined, and meanwhile, the number of bytes of the sql is set to be not more than 10 bytes, for example, the number of bytes of the sql may be selected to be 10 bytes, and the number of bytes of the sql may also be selected to be 5 bytes, in the embodiment of the present invention, the number of bytes of the sql is specifically taken to be 10 bytes.
In a specific implementation process, the sql statement corresponding to the sql statement may be selectively set as a single table operation for the database or a multi-table association operation for the database. For example, when the sql statement corresponding to the sql is selected as the multi-table association operation for the database, that is, the sql statement of the database a corresponding to the sql is the multi-table association operation for the database a, the sql statement of the database B corresponding to the sql is the multi-table association operation for the database B, and the sql statement of the database C corresponding to the sql is the multi-table association operation for the database C, then, the association operation can be performed on any two data tables or more than two data tables in the database corresponding to the sql statement through the sql statement corresponding to the sql. Specifically, the sql statement corresponding to the sql is taken as an example for operating on one data table in each database.
In practical applications, after the database access subsystem receives the database access request, the database access subsystem will execute step S102: and determining that at least two database tables need to be accessed according to the fragment field and the sqlid.
Referring to fig. 2, in practical applications, the step S102 may also be implemented as follows:
step S1021: inputting the fragment field and the sqlid as parameters into a preset third-party program for routing calculation to obtain a routing result;
step S1022: and determining at least two database tables needing to be accessed according to the routing result.
Specifically, the database access subsystem determines the sqlid, the fragment field and the data request parameter contained in the database access request according to the received database access request, then, the database access subsystem will call a third-party program, and then the fragment field and the sql id are used as parameters to be input into the third-party program for route calculation, in practical application, the third-party program can be the method, the processing logic of the scripting method is implemented by writing a scripting language, and is executed in a scripting engine of a high-level language, such as a mode of executing the JavaScript language in a java running environment, the execution efficiency of the JavaScript language is equivalent to the local binary code efficiency, the script upgrading is easier to be carried out, and because the script language is completely pictographic, the method can realize the logic processing of various routing rules of the database, and has wider support for the fragment routing.
In this embodiment, specifically, taking a third-party program as an example of a script method, the fragment field and the sqlid are input as parameters into a program corresponding to the script method to perform routing computation, where it is assumed that a routing result includes at least two database tables, and then the database access subsystem may determine at least two database tables that need to be accessed from the routing result.
In this embodiment of the present invention, specifically taking the example that the at least two database tables include a first database table and a second database table, after step S102 is executed, the following steps may be further executed:
and determining that the database type of the first database table is B, and determining that the database type of the second database table is C, wherein the database type B is different from the database type C.
In a specific practical process, the first database table may be one database table or a plurality of database tables of the same type of database, and similarly, the second database table may be one database table or a plurality of database tables of the same type of database, which is not limited herein, and after the first database table and the second database table that the database access subsystem needs to access, the database access subsystem may determine the database type of the first database table and the database type of the second database table, and in a specific practice, the database access subsystem may store the corresponding relationship between the database and the database type in a table form shown in table one:
watch 1
Database A Db2
Database B Mysql
Database C Oracle
Here, assuming that the first database table to be accessed is a table in database a and the second database table is a table in database B, the database access subsystem may determine that the database type of the first database table is Db2 and the database type of the second database table is Mysql, according to table one.
Then, the method in this embodiment will execute step S103: and determining the sql sentences for operating the at least two database tables from the sql sentences mapped by the sql.
Referring to fig. 3, in practical applications, step S103 can also be implemented as follows:
step S1031: determining an sql statement M corresponding to a database type B from the sql statements mapped by the sql, as an sql statement for operating the first database table;
step S1032: and determining an sql statement K corresponding to the database type C from the sql statements mapped by the sql as an sql statement for operating the second database table.
Specifically, after the database access subsystem determines that the database type of the first database table is Db2 and the database type of the second database table is Mysql, the database access subsystem determines, from sql statements mapped by the sql statements respectively, that an sql statement corresponding to the database type Db2 is used as an sql statement for operating the first database table and that an sql statement corresponding to the database type Mysql is used as an sql statement for operating the second database table. Here, assume that the sql statements of database a, database B, and database C to which sql is mapped are arranged as follows:
sqlid.testId.db2=values(current timestamp)
sqlid.testId.mysql=select now()
sqlid.testId.oracle=select systimestamp from dual
then, the database access subsystem selects the sql statement corresponding to the database type Db2, i.e., values (current timestamp), from the above configuration as the sql statement for operating the first database table, and selects the sql statement corresponding to the database type Mysql, i.e., select now (), as the sql statement for operating the second database table.
After the method in this embodiment has executed step S103, step S104 is executed: and combining statement parameters in the data request parameters with the sql statements and then accessing the at least two database tables to obtain access results.
In practical application, in step S102, if the fragment field and the sqlid are input as parameters into a program corresponding to the script method for performing routing calculation, and the obtained routing result further includes the database addresses and the physical table names of the first database table and the second database table, step S103 may also be performed in the following manner:
step A: combining the statement parameter, the sql statement M, the database address of the first database table and the physical table name of the first database table, and then accessing the first database table to obtain an access result;
and B: and combining the statement parameters, the sql statement K, the database address of the second database table and the physical table name of the second database table, and then accessing the second database table to obtain an access result.
That is, when the routing result further includes a database address and a physical table name of the first database table, and the database address and the physical table name of the second database table, the database access subsystem combines the database address, the physical table name, the statement parameter in the data request, and the sql statement corresponding to the type Db2 in the routing result, and then uses the combination as a parameter for accessing the first database table, and the database access subsystem combines the database address, the physical table name, the statement parameter in the data request, and the sql statement corresponding to the type Mysql in the routing result, and then uses the combination as a parameter for accessing the second database table, and obtains an access result, and then outputs the access result to the database system.
Therefore, according to the method, the sqlid is used by using the request parameter of the data access, the request parameter of the data access sqlid corresponds to the sql execution statement of the different types of databases, and the sql execution statement of the different types of databases corresponding to the sqlid is input into the corresponding database table for execution after the database tables which are required to be accessed and belong to the different types of databases are determined.
In addition, the invention uses the sqlid by using the request parameter of the data access, so that the information of the table and the field in the database can not appear in the message of the data access request, and the time-consuming operation of accessing the database table is avoided, therefore, the technical problem of low efficiency of fragment data access in the prior art can be effectively solved. The method has the beneficial effect of improving the access efficiency of the fragmented data.
In addition, because the sql language corresponding to the sql can be related to two or more tables of the database, the fragment routing of the related data operation of the database and the multiple tables is realized. Because the traditional database carries out authority control aiming at the table and the operation type, the embodiment of the invention carries out data access by using an sql mode and can carry out authority control according to each sql statement operation, therefore, the authority control strength is thinner than that of the traditional database, and simultaneously, the request parameter for database access uses sql statement instead of sql statement, so that the information of table and field in the database can not appear in the database access request message, and the function of protecting the database structure is also played.
In addition, parameters in the database access request use the sql statements and directly use the sql statements, and the sql statements use no more than 10 bytes and are far lower than the network flow required when the sql statements are used as the parameters, so the flow of the network request is also saved. The embodiment of the invention uses the script method as a third-party program, the script language is executed in the running environment of the high-level language, and the calculation efficiency of the fragment routing is higher, so that the efficiency of fragment data access is further improved.
Based on the same inventive concept, embodiments of the present invention provide a data access device, and specific implementation of data access of the device may refer to the description of the method embodiment, and repeated details are not described again, as shown in fig. 4, the device mainly includes:
the access control module 11: the method comprises the steps of obtaining a database access request, wherein the database access request comprises an sql, a fragment field and a data request parameter, and the sql maps at least sql statements of two databases of different types;
fragment routing module 12: the system comprises a data processing module, a fragment field generation module, a query field generation module and a query field generation module, wherein the fragment field generation module is used for generating a fragment field and a sqlid;
the access control module 11 is further configured to: determining an sql statement for operating the at least two database tables from the sql statement mapped by the sql, and accessing the at least two database tables after combining statement parameters in the data request parameters with the sql statement to obtain an access result.
Optionally, when the sql statements of at least two databases are mapped by the sql statements, the sql statements and the sql statements are in a one-to-many correspondence relationship.
Optionally, each sql statement corresponding to the sql is a single table operation for the database or a multi-table association operation for the database.
Optionally, the fragment routing module is specifically configured to:
inputting the fragment field and the sqlid as parameters into a preset third-party program for routing calculation to obtain a routing result;
and determining at least two database tables needing to be accessed according to the routing result.
Optionally, when the at least two database tables include a first database table and a second database table, the access control module is specifically configured to:
and determining that the database type of the first database table is B, and determining that the database type of the second database table is C, wherein the database type B is different from the database type C.
Optionally, the access control module is specifically configured to:
determining an sql statement M corresponding to a database type B from the sql statements mapped by the sql, as an sql statement for operating the first database table;
and determining an sql statement K corresponding to the database type C from the sql statements mapped by the sql as an sql statement for operating the second database table.
Optionally, the routing result further includes database addresses and physical table names of the first database table and the second database table, and the access control module is specifically configured to:
combining the statement parameter, the sql statement M, the database address of the first database table and the physical table name of the first database table, and then accessing the first database table to obtain an access result;
and combining the statement parameters, the sql statement K, the database address of the second database table and the physical table name of the second database table, and then accessing the second database table to obtain an access result.
Optionally, the number of bytes of the sqlid is less than or equal to 10 bytes.
In addition, in the data access device in the embodiment of the invention, the database access is uniformly managed, and all sql statements are centrally managed in the access control module, so that the unified management of database administrators is facilitated, the database access is more optimized, the routing rules are easy to modify and expand, the routing rules are independent of the deployment of the data access module, and the whole module of the data access is not required to be upgraded after the routing rules are modified.
Based on the same inventive concept, an embodiment of the present invention provides a data access device, and specific implementation of the device may refer to description of the method embodiment, and repeated parts are not repeated, as shown in fig. 5, the device mainly includes a processor 21 and a memory 22, where the memory 22 stores a preset program, and the processor 21 reads the program in the memory 22, and executes the following processes according to the program:
obtaining a database access request, wherein the database access request comprises an sql, a fragment field and a data request parameter, and the sql at least maps sql statements of two databases of different types;
determining that at least two databases need to be accessed according to the fragment field and the sqlid;
determining an sql statement for operating the at least two databases from the sql statement mapped by the sql;
and combining statement parameters in the data request parameters with the sql statements and then accessing the at least two databases to obtain access results.
Optionally, when the sql statements of at least two databases are mapped by the sql statements, the sql statements and the sql statements are in a one-to-many correspondence relationship.
Optionally, each sql statement corresponding to the sql is a single table operation for the database or a multi-table association operation for the database.
Optionally, the determining, according to the fragment field and the sqlid, that at least two databases need to be accessed specifically includes:
inputting the fragment field and the sqlid as parameters into a preset third-party program for routing calculation to obtain a routing result;
and determining at least two databases to be accessed according to the routing result.
Optionally, when the at least two database tables include a first database table and a second database table, the access control module is specifically configured to:
and determining that the database type of the first database table is B, and determining that the database type of the second database table is C, wherein the database type B is different from the database type C.
Optionally, the access control module is specifically configured to:
determining an sql statement M corresponding to a database type B from the sql statements mapped by the sql, as an sql statement for operating the first database table;
and determining an sql statement K corresponding to the database type C from the sql statements mapped by the sql as an sql statement for operating the second database table.
Optionally, the routing result further includes database addresses and physical table names of the first database table and the second database table, and the access control module is specifically configured to:
combining the statement parameter, the sql statement M, the database address of the first database table and the physical table name of the first database table, and then accessing the first database table to obtain an access result;
and combining the statement parameters, the sql statement K, the database address of the second database table and the physical table name of the second database table, and then accessing the second database table to obtain an access result.
Optionally, the number of bytes of the sqlid is less than or equal to 10 bytes.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (9)

1. A method of data access, comprising:
obtaining a database access request, wherein the database access request comprises an sql, a fragment field and a data request parameter, and the sql at least maps sql statements of two databases of different types;
inputting the fragment field and the sqlid as parameters into a preset third-party program for routing calculation to obtain a routing result;
determining at least two database tables needing to be accessed according to the routing result, wherein the at least two database tables belong to different types of databases; the at least two database tables comprise a first database table and a second database table; the routing result comprises data, library addresses and physical table names of the first database table and the second database table;
determining an sql statement M corresponding to a database type B from the sql statements mapped by the sql, as an sql statement for operating the first database table;
determining an sql statement K corresponding to a database type C from the sql statements mapped by the sql, as an sql statement for operating the second database table;
combining statement parameters in the data request parameters, the sql statement M, the database address of the first database table and the physical table name of the first database table, and then accessing the first database table to obtain an access result;
and combining the statement parameters, the sql statement K, the database address of the second database table and the physical table name of the second database table, and then accessing the second database table to obtain an access result.
2. The method of claim 1, wherein when the sql is mapped to at least sql statements of two different types of databases, the sql and the sql statements are in one-to-many correspondence.
3. The method of claim 2, wherein each sql statement to which the sql corresponds is a single table operation for a database or is a multi-table association operation for a database.
4. The method of claim 1, after determining that at least two database tables need to be accessed, comprising:
and determining that the database type of the first database table is B, and determining that the database type of the second database table is C, wherein the database type B is different from the database type C.
5. The method of any of claims 1-4, wherein the sqlid has a byte count of 10 bytes or less.
6. A data access device, comprising:
an access control module: the method comprises the steps of obtaining a database access request, wherein the database access request comprises an sql, a fragment field and a data request parameter, and the sql maps at least sql statements of two databases of different types;
a fragment routing module: the system comprises a fragmentation field, a sqlid and a third-party program, wherein the fragmentation field and the sqlid are used as parameters and input into the preset third-party program for carrying out routing calculation to obtain a routing result;
the fragment routing module: the routing module is also used for determining at least two database tables needing to be accessed according to the routing result, wherein the at least two database tables belong to different types of databases; the at least two database tables comprise a first database table and a second database table; the routing result comprises data, library addresses and physical table names of the first database table and the second database table;
the access control module is further configured to: determining an sql statement M corresponding to a database type B from the sql statements mapped by the sql, as an sql statement for operating the first database table;
the access control module is further configured to: determining an sql statement K corresponding to a database type C from the sql statements mapped by the sql, as an sql statement for operating the second database table;
the access control module is further configured to: combining statement parameters in the data request parameters, the sql statement M, the database address of the first database table and the physical table name of the first database table, and then accessing the first database table to obtain an access result;
the access control module is further configured to: and combining the statement parameters, the sql statement K, the database address of the second database table and the physical table name of the second database table, and then accessing the second database table to obtain an access result.
7. The apparatus of claim 6, in which when the sql is mapped to at least two databases, the sql corresponds to the sql statement in a one-to-many manner.
8. The apparatus of claim 7, in which each sql statement to which the sql corresponds is a single table operation for a database or is a multi-table association operation for a database.
9. The device of claim 6, wherein when the at least two database tables include a first database table and a second database table, the access control module is specifically configured to:
and determining that the database type of the first database table is B, and determining that the database type of the second database table is C, wherein the database type B is different from the database type C.
CN201710548153.3A 2017-07-06 2017-07-06 Data access method and equipment Active CN107451201B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710548153.3A CN107451201B (en) 2017-07-06 2017-07-06 Data access method and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710548153.3A CN107451201B (en) 2017-07-06 2017-07-06 Data access method and equipment

Publications (2)

Publication Number Publication Date
CN107451201A CN107451201A (en) 2017-12-08
CN107451201B true CN107451201B (en) 2020-12-04

Family

ID=60488775

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710548153.3A Active CN107451201B (en) 2017-07-06 2017-07-06 Data access method and equipment

Country Status (1)

Country Link
CN (1) CN107451201B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1904885A (en) * 2005-07-29 2007-01-31 北京航空航天大学 Database adapter
KR100877156B1 (en) * 2008-04-17 2009-01-07 (주)아이티엑스퍼트그룹 System and method of access path analysis for dynamic sql before executed
CN102033889A (en) * 2009-09-29 2011-04-27 熊凡凡 Distributed database parallel processing system
CN102750384A (en) * 2012-06-28 2012-10-24 用友软件股份有限公司 Device and method for acquiring data from multidatabase engine
CN104166705A (en) * 2014-08-06 2014-11-26 广州华多网络科技有限公司 Access method and device of database
CN105930387A (en) * 2016-04-14 2016-09-07 北京思特奇信息技术股份有限公司 Data operation system and method based on data routing and sharding

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101196926A (en) * 2007-12-29 2008-06-11 中国建设银行股份有限公司 Database access platform and access method thereof
CN103176974B (en) * 2011-12-20 2016-01-13 国际商业机器公司 The method and apparatus of access path in optimization data storehouse
CN106202441A (en) * 2016-07-13 2016-12-07 腾讯科技(深圳)有限公司 Data processing method based on relevant database, device and system
CN106294565A (en) * 2016-07-27 2017-01-04 中国农业银行股份有限公司 A kind of data bank access method and system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1904885A (en) * 2005-07-29 2007-01-31 北京航空航天大学 Database adapter
KR100877156B1 (en) * 2008-04-17 2009-01-07 (주)아이티엑스퍼트그룹 System and method of access path analysis for dynamic sql before executed
CN102033889A (en) * 2009-09-29 2011-04-27 熊凡凡 Distributed database parallel processing system
CN102750384A (en) * 2012-06-28 2012-10-24 用友软件股份有限公司 Device and method for acquiring data from multidatabase engine
CN104166705A (en) * 2014-08-06 2014-11-26 广州华多网络科技有限公司 Access method and device of database
CN105930387A (en) * 2016-04-14 2016-09-07 北京思特奇信息技术股份有限公司 Data operation system and method based on data routing and sharding

Also Published As

Publication number Publication date
CN107451201A (en) 2017-12-08

Similar Documents

Publication Publication Date Title
US11163731B1 (en) Autobuild log anomaly detection methods and systems
CN107391622B (en) Data access method and equipment
CN110795455B (en) Dependency analysis method, electronic device, computer apparatus, and readable storage medium
US8661023B1 (en) Optimizing search query logic to speed retrieval
CN111813805A (en) Data processing method and device
CN113641701B (en) Data query method, system, heterogeneous acceleration platform and storage medium
WO2018036549A1 (en) Distributed database query method and device, and management system
CN111221840A (en) Data processing method and device, data caching method, storage medium and system
CN110990420A (en) Data query method and device
CN107016039B (en) Database writing method and database system
CN110941602B (en) Database configuration method and device, electronic equipment and storage medium
CN105989015B (en) Database capacity expansion method and device and method and device for accessing database
CN109376153B (en) System and method for writing data into graph database based on NiFi
CN112163048A (en) Method and device for realizing OLAP analysis based on ClickHouse
CN107491700B (en) Data access method and equipment
CN114090695A (en) Query optimization method and device for distributed database
CN110990350B (en) Log analysis method and device
CN104598652B (en) A kind of data base query method and device
CN111475511A (en) Data storage method, data access method, data storage device, data access device and data access equipment based on tree structure
CN110737603A (en) method and device for replacing functions in ROM
CN107451201B (en) Data access method and equipment
CN107506369A (en) A kind of data access method and equipment
CN111125090A (en) Data access method and device
CN110858199A (en) Document data distributed computing method and device
CN106294721B (en) Cluster data counting and exporting methods and devices

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