CN109492053B - Method and device for accessing data - Google Patents

Method and device for accessing data Download PDF

Info

Publication number
CN109492053B
CN109492053B CN201811324189.4A CN201811324189A CN109492053B CN 109492053 B CN109492053 B CN 109492053B CN 201811324189 A CN201811324189 A CN 201811324189A CN 109492053 B CN109492053 B CN 109492053B
Authority
CN
China
Prior art keywords
data
target
interface
sql
blockchain
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
CN201811324189.4A
Other languages
Chinese (zh)
Other versions
CN109492053A (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.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology 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 Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201811324189.4A priority Critical patent/CN109492053B/en
Publication of CN109492053A publication Critical patent/CN109492053A/en
Application granted granted Critical
Publication of CN109492053B publication Critical patent/CN109492053B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • 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

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application discloses a method and a device for accessing data. One embodiment of the method comprises the following steps: receiving a Structured Query Language (SQL) instruction; analyzing the SQL instruction and determining the data access type indicated by the SQL instruction; an interface matching the data access type running in the smart contract of the target blockchain is invoked, through which data access operations are performed on the target blockchain. This embodiment enables flexibility in accessing data stored in the blockchain.

Description

Method and device for accessing data
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to a method and a device for accessing data.
Background
The blockchain is a decentralized database with decentralization and trust removal, and recorded information can be effectively prevented from being tampered through a consensus mechanism and an encryption algorithm, so that traceability is achieved. Smart contracts are digitally defined commitments that include agreements on which contract participants can perform these commitments. The intelligent contracts run in the block chain and interact with the outside to realize the read-write operation of the block chain data.
The development mode of the block chain is not well known by a large number of developers, the operation mode of data in the block chain is generally unknown to the developers, and the mode of data structure design and development application based on the block chain is unclear, so that the development of the application based on the block chain storage is difficult. In a related manner, a developer can develop, deploy and call an intelligent contract to perform read-write operation on data stored in the blockchain.
Disclosure of Invention
The embodiment of the application provides a method and a device for accessing data.
In a first aspect, embodiments of the present application provide a method for accessing data, the method comprising: receiving a Structured Query Language (SQL) instruction; analyzing the SQL instruction and determining the data access type indicated by the SQL instruction; and calling an interface matched with the data access type in the intelligent contract operated by the target blockchain, and executing data access operation on the target blockchain through the interface.
In some embodiments, invoking an interface in the intelligent contract run by the target blockchain that matches the data access type, performing a data access operation on the target blockchain through the interface, comprising: and in response to determining that the data access type is a read-only type, calling a first target interface running in an intelligent contract of the target blockchain, and querying target data in the target blockchain through the first target interface, wherein the target data is data to be queried indicated by an SQL instruction, and the first target interface is used for querying the data stored in the target blockchain.
In some embodiments, invoking an interface in the intelligent contract run by the target blockchain that matches the data access type, performing a data access operation on the target blockchain through the interface, comprising: in response to determining that the data access type is a read-write type, invoking a first target interface running in an intelligent contract of a target blockchain, querying target data in the target blockchain through the first target interface, wherein the target data is data to be updated indicated by an SQL instruction, and the first target interface is used for querying data stored in the target blockchain; and calling a second target interface in the intelligent contract operated by the target block chain, and storing the data updated with the target data in the target block chain through the second target interface, wherein the second target interface is used for storing the data in the target block chain.
In some embodiments, the method further comprises: and returning an execution result after the data access operation is executed.
In some embodiments, returning the execution result after executing the data access operation includes: responding to the data access type which is determined to be a read-only type, and returning data to be queried indicated by the SQL instruction; in response to determining that the data access type is a read-write type, hint information is returned that characterizes whether the write was successful.
In a second aspect, embodiments of the present application provide an apparatus for accessing data, the apparatus comprising: a receiving unit configured to receive a Structured Query Language (SQL) instruction; the analyzing unit is configured to analyze the SQL instruction and determine the data access type indicated by the SQL instruction; and the access unit is configured to call an interface matched with the data access type in the intelligent contract operated by the target blockchain, and perform data access operation on the target blockchain by using the interface.
In some embodiments, the access unit is further configured to: and in response to determining that the data access type is a read-only type, calling a first target interface in an intelligent contract operated by the target blockchain, and querying target data in the target blockchain through the first target interface, wherein the target data is data to be queried indicated by an SQL instruction, and the first target interface is used for querying the data stored in the target blockchain.
In some embodiments, the access unit is further configured to: in response to determining that the data access type is a read-write type, invoking a first target interface in an intelligent contract operated by a target blockchain, querying target data in the target blockchain through the first target interface, wherein the target data is data to be updated indicated by an SQL instruction, and the first target interface is used for querying data stored in the target blockchain; and calling a second target interface in the intelligent contract operated by the target block chain, and storing the data updated with the target data in the target block chain through the second target interface, wherein the second target interface is used for storing the data in the target block chain.
In some embodiments, the apparatus further comprises: and the return unit is configured to return an execution result after the data access operation is executed.
In some embodiments, the return unit is further configured to: responding to the data access type which is determined to be a read-only type, and returning data to be queried indicated by the SQL instruction; in response to determining that the data access type is a read-write type, hint information is returned that characterizes whether the write was successful.
In a third aspect, an embodiment of the present application provides an electronic device, including: one or more processors; a storage device having one or more programs stored thereon, which when executed by one or more processors, cause the one or more processors to implement the method of any of the first aspects described above.
In a fourth aspect, embodiments of the present application provide a computer readable medium having stored thereon a computer program which, when executed by a processor, implements a method as in any of the first aspects described above.
According to the method and the device for accessing the data, the received SQL instruction is analyzed so as to call the interface matched with the data access type in the intelligent contract operated by the target blockchain, so that the data access operation is performed on the target blockchain through the interface, the access to the target blockchain can be realized through the SQL instruction, and the flexibility of the access to the data stored in the blockchain is improved.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the detailed description of non-limiting embodiments, made with reference to the following drawings, in which:
FIG. 1 is an exemplary system architecture diagram in which an embodiment of the present application may be applied;
FIG. 2 is a flow chart of one embodiment of a method for accessing data according to the present application;
FIG. 3 is a schematic illustration of one application scenario of a method for accessing data according to the present application;
FIG. 4 is a flow chart of yet another embodiment of a method for accessing data according to the present application;
FIG. 5 is a schematic structural diagram of one embodiment of an apparatus for accessing data according to the present application;
fig. 6 is a schematic diagram of a computer system suitable for use in implementing embodiments of the present application.
Detailed Description
The present application is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be noted that, for convenience of description, only the portions related to the present invention are shown in the drawings.
It should be noted that, in the case of no conflict, the embodiments and features in the embodiments may be combined with each other. The present application will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 illustrates an exemplary system architecture 100 to which the methods for accessing data or apparatuses for accessing data of the present application may be applied.
As shown in fig. 1, a system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used as a medium to provide communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
The user may interact with the server 105 via the network 104 using the terminal devices 101, 102, 103 to receive or send messages or the like. Various communication client applications, such as a voice interaction type application, a shopping type application, a search type application, an instant messaging tool, a mailbox client, social platform software, etc., may be installed on the terminal devices 101, 102, 103.
The terminal devices 101, 102, 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they may be various electronic devices having a display screen and supporting network communications, including but not limited to smartphones, tablets, laptop and desktop computers, and the like. When the terminal devices 101, 102, 103 are software, they can be installed in the above-listed electronic devices. Which may be implemented as multiple software or software modules (e.g., to provide distributed services), or as a single software or software module. The present invention is not particularly limited herein.
The server 105 may be a server for maintaining a target blockchain, such as a node server that stores a complete record of the target blockchain. The node server may query the data in the target blockchain, write new data in the target blockchain, or perform data processing (for example, update data), and return a processing result (using an execution result after executing the data access operation) to the terminal device.
The server 105 may be hardware or software. When the server is hardware, the server may be implemented as a distributed server cluster formed by a plurality of servers, or may be implemented as a single server. When the server is software, it may be implemented as a plurality of software or software modules (e.g., to provide distributed services), or as a single software or software module. The present invention is not particularly limited herein.
It should be noted that, the method for accessing data provided in the embodiments of the present application is generally performed by the server 105, and accordingly, the device for accessing data is generally disposed in the server 105.
It should be understood that the number of terminal devices, networks and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continued reference to FIG. 2, a flow 200 of one embodiment of a method for accessing data according to the present application is shown. The method for accessing data comprises the following steps:
step 201, receive SQL instruction.
In this embodiment, the execution body of the method for accessing data (e.g., the server 105 shown in fig. 1) may receive the SQL (Structured Query Language ) instruction sent by the client (e.g., the terminal devices 101, 102, 103 shown in fig. 1) by using a wired connection or a wireless connection. Herein, an SQL instruction may be understood as an SQL statement. For example, the SQL statement "SELECT LastName, firstName FROM Persons" is used to indicate that the contents of the columns named "LastName" and "FirstName" are retrieved FROM a data table named "Persons".
It should be noted that the wireless connection may include, but is not limited to, 3G/4G connections, wiFi connections, bluetooth connections, wiMAX connections, zigbee connections, UWB (ultra wideband) connections, and other now known or later developed wireless connection means.
In practice, SQL is a special purpose programming language, a database query and programming language, for accessing data and querying, updating and managing relational database systems. SQL is a high-level, non-procedural programming language that allows users to work on high-level data structures. The method does not require the user to specify a data storage method or the user to know a specific data storage mode, so that different database systems with completely different substructures can use the same structured query language as an interface for data input and management. Thus, the blockchain may be used as an underlying data storage structure, with SQL instructions being used to perform access operations to the blockchain. Therefore, a developer can access the blockchain storage in a development mode similar to the traditional database, and the development cost of the blockchain application program is reduced. Meanwhile, the blockchain is used as the bottom layer of the database for storage, so that the data cannot be tampered privately, and the safety of the data is ensured.
Step 202, parse the SQL instruction, confirm the data access type indicated by SQL instruction.
In this embodiment, the execution body may parse the SQL instruction to determine a data access type indicated by the SQL instruction. Here, the data access type may include, but is not limited to, a read-only type, a read-write type, and the like. Here, the analysis of the SQL command may be performed in various ways.
As an example, the parsing of the SQL instructions described above may be performed using an existing SQL parser.
As yet another example, the execution body may have a set of SQL instruction keywords preset therein. In addition, the execution main body may be preset with a correspondence table, where the correspondence table may be used to characterize a correspondence between the SQL instruction keyword and the data access type. Here, the SQL instruction received in step 201 may be first matched with the SQL instruction keywords in the preset SQL instruction keyword set, so as to identify the keywords of the SQL instruction. And then, searching the data access type corresponding to the matched keyword in the corresponding relation table.
It should be noted that, in the above example, the SQL instruction keyword may be a word used for characterizing an operation purpose, such as "SELECT", "INSERT", or the like.
Step 203, calling an interface matched with the data access type in the intelligent contract operated by the target blockchain, and executing data access operation on the target blockchain through the interface.
In this embodiment, the execution body may call an interface in the intelligent contract operated by the target blockchain, which is matched with the data access type, and execute a data access operation on the target blockchain through the interface.
Here, the execution subject may store in advance correspondence information of the data access type and the interface running in the intelligent contract of the target blockchain. The execution body may directly query the interface with the data access type determined in step 202 from the correspondence, and execute the data access operation on the target blockchain through the interface.
Here, for a certain data access type, the interface corresponding to the data access type may be used to perform a data access operation of the data access type on the target blockchain.
It should be noted that the target blockchain may be a blockchain maintained by the execution body. The execution body may store a complete record of the target blockchain. In practice, the target blockchain may use a variety of existing blockchains. Such as supporting super ledgers (e.g., fabric), ethernet, blockchains developed by the enterprise itself, etc.
In practice, smart contracts are digitally defined commitments, including agreements on which contract participants may perform these commitments. The intelligent contracts run in the block chain and interact with the outside to realize the read-write operation of the block chain data. It should be noted that the above intelligent contracts are known techniques widely studied and applied at present, and are not described herein.
In some optional implementations of this embodiment, in response to determining that the data access type is a read-only type, the executing entity may invoke a first target interface (e.g., a Query (key) interface) in an intelligent contract operated by a target blockchain through which target data in the target blockchain is queried. The target data may be data to be queried indicated by the SQL instruction. The first target interface may be configured to query data stored in the target blockchain.
In some optional implementations of the present embodiment, in response to determining that the data access type is a read-write type, the executing entity may execute the following steps:
first, the execution subject may invoke a first target interface in an intelligent contract run by a target blockchain to query target data in the target blockchain through the first target interface. Here, the target data may be data to be updated indicated by the SQL instruction. The first target interface may be configured to query data stored in the target blockchain.
In the second step, the executing body may call a second target interface (for example, a Put (key) interface) in the intelligent contract operated by the target blockchain, and store the data updated to the target data in the target blockchain through the second target interface. The second target interface is used for storing data in the target block chain.
In some optional implementations of this embodiment, after the execution body performs the data access operation, the execution body may return an execution result after the execution of the data access operation. Specifically, in response to determining that the data access type is a read-only type, data to be queried indicated by the SQL instruction may be returned; in response to determining that the data access type is a read-write type, a hint information may be returned that characterizes whether the write was successful. As an example, if the data access operation is a read-only query for one or more data, the execution body may return the queried data or data set. As yet another example, if the data access operation is writing certain data, the execution body may return a hint information indicating whether writing was successful.
With continued reference to fig. 3, fig. 3 is a schematic diagram of an application scenario of the method for accessing data according to the present embodiment. In the application scenario of fig. 3, the user first sends an SQL instruction to the blockchain system 303 using the terminal device 301. A plurality of node servers may be included in the blockchain system 303. Each node server may be configured to maintain a target blockchain, e.g., a complete record of the target blockchain is stored. The target blockchain may be run with a smart contract.
After sending the SQL instruction, any node server in the blockchain system 303 may parse the SQL instruction to determine the data access type indicated by the SQL instruction. The node server may then invoke an interface in the intelligent contract running on the target blockchain that matches the data access type, through which data access operations are performed on the target blockchain. The blockchain system is understood to be composed of three layers, namely an SQL interface layer, an SQL adapting layer and a blockchain storage layer. The SQL interface layer may support standard SQL, JDBC (Java DataBase Connectivity, java database connection), ODBC (Open Database Connectivity, open database connection), and other commonly used SQL access services, and SQL grammar checking. The SQL adaptation layer can convert the SQL command received by an upper layer (namely the SQL interface layer) into an intelligent contract instruction to operate the blockchain ledger data. The blockchain storage layer may store data.
According to the method provided by the embodiment of the application, the received SQL instruction is analyzed so as to call the interface matched with the data access type in the intelligent contract operated by the target blockchain, so that the data access operation is performed on the target blockchain through the interface, and therefore, the target blockchain can be accessed through the SQL instruction, and the flexibility of accessing the data stored in the blockchain is improved. Because the development mode of the blockchain is not well known by the majority of developers, the operation mode of the data in the blockchain is generally and poorly known by the developers, and the mode of the data structure design and development application based on the blockchain is unclear, so that the development of the application based on the blockchain storage becomes difficult. By the method provided by the embodiment of the application, an access mode using SQL instructions can be provided for an developer, and the use threshold of block chain storage is reduced. Meanwhile, the conventional database can realize the migration of data into the blockchain with only a small amount of modification. The uplink service can use the characteristics of decentralization, tamper resistance and the like of the uplink block chain.
With further reference to FIG. 4, a flow 400 of yet another embodiment of a method for accessing data is shown. The flow 400 of the method for accessing data includes the steps of:
step 401, receive SQL instructions.
In this embodiment, the execution body of the method for accessing data (e.g., the server 105 shown in fig. 1) may receive the SQL (Structured Query Language ) instruction sent by the client (e.g., the terminal devices 101, 102, 103 shown in fig. 1) by using a wired connection or a wireless connection. Herein, an SQL instruction may be understood as an SQL statement. For example, the SQL statement "SELECT LastName, firstName FROM Persons" is used to indicate that the contents of the columns named "LastName" and "FirstName" are retrieved FROM a data table named "Persons".
Step 402, parse the SQL instruction, confirm the data access type indicated by SQL instruction.
In this embodiment, the execution body may parse the SQL instruction to determine a data access type indicated by the SQL instruction. Here, the data access type may include, but is not limited to, a read-only type, a read-write type, and the like. Here, the operation of parsing the SQL instruction is substantially the same as the operation of step 201, and will not be described herein.
In step 403, in response to determining that the data access type is a read-only type, a first target interface in the intelligent contract operated by the target blockchain is invoked, and target data in the target blockchain is queried through the first target interface.
In this embodiment, in response to determining that the data access type is a read-only type, the execution body may invoke a first target interface (e.g., a Query (key) interface) in an intelligent contract operated by a target blockchain, and Query target data in the target blockchain through the first target interface. The target data may be data to be queried indicated by the SQL instruction. The first target interface may be configured to query data stored in the target blockchain.
In step 404, in response to determining that the data access type is a read-write type, a first target interface in the intelligent contract operated by the target blockchain is invoked, and target data in the target blockchain is queried through the first target interface.
In this embodiment, in response to determining that the data access type is a read-write type, the execution body may invoke a first target interface in an intelligent contract operated by a target blockchain, and query target data in the target blockchain through the first target interface. Here, the target data may be data to be updated indicated by the SQL instruction. The first target interface may be configured to query data stored in the target blockchain.
Step 405, call a second target interface in the intelligent contract operated by the target blockchain, and store the data updated to the target data in the target blockchain through the second target interface.
In this embodiment, the executing body may call a second target interface (for example, a Put (key) interface) in the intelligent contract operated by the target blockchain, and store the data updated to the target data in the target blockchain through the second target interface. The second target interface is used for storing data in the target block chain.
And step 406, returning an execution result after the data access operation is executed.
In this embodiment, after the execution body performs the data access operation, the execution body may return an execution result after the execution of the data access operation. As an example, if the data access operation is a read-only query for certain data, the execution body may return the queried data. As yet another example, if the data access operation is writing certain data, the execution body may return a hint information indicating whether writing was successful.
As can be seen from fig. 4, compared to the corresponding embodiment of fig. 2, the flow 400 of the method for accessing data in this embodiment involves performing the operation of blockchain data access for the read-only type, read-write type SQL instruction. Therefore, the intelligent contract accessed by the blockchain storage can be adapted, an access mode using SQL instructions is provided for an issuer, and the use threshold of the blockchain storage is reduced. Meanwhile, the conventional database can realize the migration of data into the blockchain with only a small amount of modification. The uplink service can use the characteristics of decentralization, tamper resistance and the like of the uplink block chain.
With further reference to fig. 5, as an implementation of the method shown in the foregoing figures, the present application provides an embodiment of an apparatus for accessing data, where the embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 2, and the apparatus is particularly applicable to various electronic devices.
As shown in fig. 5, an apparatus 500 for accessing data according to the present embodiment includes: a receiving unit 501 configured to receive a structured query language SQL instruction; the parsing unit 502 is configured to parse the SQL instruction and determine a data access type indicated by the SQL instruction; and an access unit 503 configured to call an interface matching the data access type in the intelligent contract operated by the target blockchain, and perform a data access operation on the target blockchain using the interface.
In some optional implementations of this embodiment, the access unit 503 may be further configured to: and in response to determining that the data access type is a read-only type, calling a first target interface in an intelligent contract operated by a target block chain, and querying target data in the target block chain through the first target interface, wherein the target data is data to be queried indicated by the SQL instruction, and the first target interface is used for querying data stored in the target block chain.
In some optional implementations of this embodiment, the access unit 503 may be further configured to: in response to determining that the data access type is a read-write type, calling a first target interface in an intelligent contract operated by a target block chain, and inquiring target data in the target block chain through the first target interface, wherein the target data is data to be updated indicated by the SQL instruction, and the first target interface is used for inquiring data stored in the target block chain; and calling a second target interface in the intelligent contract operated by the target block chain, and storing the data updated by the target data in the target block chain through the second target interface, wherein the second target interface is used for storing the data in the target block chain.
In some alternative implementations of the present embodiment, the apparatus may further include a return unit (not shown in the figures). Wherein the return unit may be configured to return an execution result after the data access operation is executed.
In some embodiments, the return unit may be further configured to: responding to the data access type which is determined to be a read-only type, and returning data to be queried indicated by the SQL instruction; in response to determining that the data access type is a read-write type, hint information is returned that characterizes whether the write was successful.
According to the device provided by the embodiment of the application, the SQL instruction received by the receiving unit 501 is analyzed through the analyzing unit 502, so that the accessing unit 503 calls the interface matched with the data access type in the intelligent contract operated by the target blockchain, and thus the data access operation is performed on the target blockchain through the interface, and therefore the access to the target blockchain can be realized through the SQL instruction, and the flexibility of accessing the data stored in the blockchain is improved. Because the development mode of the blockchain is not well known by the majority of developers, the operation mode of the data in the blockchain is generally and poorly known by the developers, and the mode of the data structure design and development application based on the blockchain is unclear, so that the development of the application based on the blockchain storage becomes difficult. By the method provided by the embodiment of the application, an access mode using SQL instructions can be provided for an developer, and the use threshold of block chain storage is reduced. Meanwhile, the conventional database can realize the migration of data into the blockchain with only a small amount of modification. The uplink service can use the characteristics of decentralization, tamper resistance and the like of the uplink block chain.
Referring now to FIG. 6, a schematic diagram of a computer system 600 suitable for use in implementing an electronic device of an embodiment of the present application is shown. The electronic device shown in fig. 6 is only an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present application.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, mouse, etc.; an output portion 607 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The drive 610 is also connected to the I/O interface 605 as needed. Removable media 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is installed as needed on drive 610 so that a computer program read therefrom is installed as needed into storage section 608.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network through the communication portion 609, and/or installed from the removable medium 611. The above-described functions defined in the method of the present application are performed when the computer program is executed by a Central Processing Unit (CPU) 601. It should be noted that, the computer readable medium described in the present application may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present application, however, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units involved in the embodiments of the present application may be implemented by software, or may be implemented by hardware. The described units may also be provided in a processor, for example, described as: a processor includes a receiving unit, a parsing unit, and an access unit. Where the names of these units do not constitute a limitation on the unit itself in some cases, for example, a receiving unit may also be described as "a unit that receives structured query language, SQL, instructions".
As another aspect, the present application also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by the apparatus, cause the apparatus to: receiving a Structured Query Language (SQL) instruction; analyzing the SQL instruction and determining the data access type indicated by the SQL instruction; an interface matching the data access type running in the smart contract of the target blockchain is invoked, through which data access operations are performed on the target blockchain.
The foregoing description is only of the preferred embodiments of the present application and is presented as a description of the principles of the technology being utilized. It will be appreciated by persons skilled in the art that the scope of the invention referred to in this application is not limited to the specific combinations of features described above, but it is intended to cover other embodiments in which any combination of features described above or equivalents thereof is possible without departing from the spirit of the invention. Such as the above-described features and technical features having similar functions (but not limited to) disclosed in the present application are replaced with each other.

Claims (12)

1. A method for accessing data, comprising:
receiving a Structured Query Language (SQL) instruction;
analyzing the SQL instruction and determining the data access type indicated by the SQL instruction;
calling an interface matched with the data access type in an intelligent contract operated by a target blockchain, executing data access operation on the target blockchain through the interface so as to use the target blockchain as a data storage structure of a bottom layer, and performing access operation on the target blockchain by using the SQL instruction; the performing, by the interface, a data access operation on the target blockchain includes: the SQL interface layer supports standard SQL access service and SQL grammar check, the SQL adaptation layer converts the SQL instruction received by the SQL interface layer into an intelligent contract instruction, the data of the target blockchain is operated, and the data after operation is stored by the blockchain storage layer.
2. The method for accessing data according to claim 1, wherein invoking an interface in a smart contract run by a target blockchain that matches the data access type, performing a data access operation on the target blockchain through the interface, comprises:
and in response to determining that the data access type is a read-only type, calling a first target interface in an intelligent contract operated by a target blockchain, and querying target data in the target blockchain through the first target interface, wherein the target data is data to be queried indicated by the SQL instruction, and the first target interface is used for querying the data stored in the target blockchain.
3. The method for accessing data according to claim 1, wherein invoking an interface in a smart contract run by a target blockchain that matches the data access type, performing a data access operation on the target blockchain through the interface, comprises:
in response to determining that the data access type is a read-write type, calling a first target interface in an intelligent contract operated by a target block chain, and querying target data in the target block chain through the first target interface, wherein the target data is data to be updated indicated by the SQL instruction, and the first target interface is used for querying the data stored in the target block chain;
and calling a second target interface in the intelligent contract operated by the target block chain, and storing the data updated with the target data in the target block chain through the second target interface, wherein the second target interface is used for storing the data in the target block chain.
4. The method for accessing data according to claim 1, wherein the method further comprises:
and returning an execution result after the data access operation is executed.
5. The method for accessing data according to claim 4, wherein said returning an execution result after executing said data access operation comprises:
responding to the data access type which is determined to be a read-only type, and returning data to be queried indicated by the SQL instruction;
and returning prompt information for representing whether the data access type is a read-write type or not in response to the fact that the data access type is the read-write type.
6. An apparatus for accessing data, comprising:
a receiving unit configured to receive a Structured Query Language (SQL) instruction;
the analyzing unit is configured to analyze the SQL instruction and determine the data access type indicated by the SQL instruction;
an access unit configured to invoke an interface in an intelligent contract run by a target blockchain, the interface matching the data access type, perform a data access operation on the target blockchain with the interface, so as to use the target blockchain as a data storage structure of a bottom layer, and perform an access operation on the target blockchain with the SQL instruction; the access unit is further configured to: the SQL interface layer supports standard SQL access service and SQL grammar check, the SQL adaptation layer converts the SQL instruction received by the SQL interface layer into an intelligent contract instruction, the data of the target blockchain is operated, and the data after operation is stored by the blockchain storage layer.
7. The apparatus for accessing data according to claim 6, wherein the access unit is further configured to:
and in response to determining that the data access type is a read-only type, calling a first target interface in an intelligent contract operated by a target blockchain, and querying target data in the target blockchain through the first target interface, wherein the target data is data to be queried indicated by the SQL instruction, and the first target interface is used for querying the data stored in the target blockchain.
8. The apparatus for accessing data according to claim 6, wherein the access unit is further configured to:
in response to determining that the data access type is a read-write type, calling a first target interface in an intelligent contract operated by a target block chain, and querying target data in the target block chain through the first target interface, wherein the target data is data to be updated indicated by the SQL instruction, and the first target interface is used for querying the data stored in the target block chain;
and calling a second target interface in the intelligent contract operated by the target block chain, and storing the data updated with the target data in the target block chain through the second target interface, wherein the second target interface is used for storing the data in the target block chain.
9. The apparatus for accessing data according to claim 6, wherein said apparatus further comprises:
and the return unit is configured to return an execution result after the data access operation is executed.
10. The apparatus for accessing data according to claim 9, wherein the return unit is further configured to:
responding to the data access type which is determined to be a read-only type, and returning data to be queried indicated by the SQL instruction;
and returning prompt information for representing whether the data access type is a read-write type or not in response to the fact that the data access type is the read-write type.
11. An electronic device, comprising:
one or more processors;
a storage device having one or more programs stored thereon,
when executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-5.
12. A computer readable medium having stored thereon a computer program, wherein the program when executed by a processor implements the method of any of claims 1-5.
CN201811324189.4A 2018-11-08 2018-11-08 Method and device for accessing data Active CN109492053B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811324189.4A CN109492053B (en) 2018-11-08 2018-11-08 Method and device for accessing data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811324189.4A CN109492053B (en) 2018-11-08 2018-11-08 Method and device for accessing data

Publications (2)

Publication Number Publication Date
CN109492053A CN109492053A (en) 2019-03-19
CN109492053B true CN109492053B (en) 2023-07-18

Family

ID=65695266

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811324189.4A Active CN109492053B (en) 2018-11-08 2018-11-08 Method and device for accessing data

Country Status (1)

Country Link
CN (1) CN109492053B (en)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110177079B (en) * 2019-04-17 2021-10-15 北京百度网讯科技有限公司 Calling system and calling method of intelligent contract
CN110309196A (en) * 2019-05-22 2019-10-08 深圳壹账通智能科技有限公司 Block chain data storage and query method, apparatus, equipment and storage medium
US11204933B2 (en) 2019-05-23 2021-12-21 Advanced New Technologies Co., Ltd. Data manipulation record storage method, system, apparatus, and device
CN110275916B (en) * 2019-05-23 2021-01-12 创新先进技术有限公司 Data operation record storage method, system, device and equipment
US10726002B1 (en) * 2019-08-19 2020-07-28 DLT Global Inc. Relational data management and organization using DLT
CN111506577B (en) * 2020-04-13 2023-08-22 杭州溪塔科技有限公司 Data operation method and device based on multiple state organization modes on block chain
CN113836175A (en) * 2020-06-24 2021-12-24 浙江宇视科技有限公司 Data access method, device, equipment and storage medium
CN112306645B (en) 2020-12-24 2021-05-04 北京百度网讯科技有限公司 Transaction processing method, device, equipment and medium for Ether house virtual machine
CN113157723B (en) * 2021-04-06 2022-06-03 福州大学 SQL access method for Hyperridge Fabric

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017153495A1 (en) * 2016-03-08 2017-09-14 Appii Pty Ltd A system and method for creating a database of independently validated educational and work experience profiles (curricula vitae) using blockchain smart contracts
CN107819829A (en) * 2017-10-17 2018-03-20 上海点融信息科技有限责任公司 Access method, system, block chain node device and the user terminal of block chain
CN108647361A (en) * 2018-05-21 2018-10-12 中国工商银行股份有限公司 A kind of date storage method, apparatus and system based on block chain

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101400214B1 (en) * 2013-01-28 2014-05-28 주식회사 알티베이스 Appratus for providing a hybrid c interface
US20150261507A1 (en) * 2014-03-14 2015-09-17 Raghuvira Bhagavan Validating sql queries in a report
US10089489B2 (en) * 2015-06-02 2018-10-02 ALTR Solutions, Inc. Transparent client application to arbitrate data storage between mutable and immutable data repositories
US10169601B2 (en) * 2015-11-18 2019-01-01 American Express Travel Related Services Company, Inc. System and method for reading and writing to big data storage formats
US10142312B2 (en) * 2016-02-22 2018-11-27 Bank Of America Corporation System for establishing secure access for users in a process data network
US10496989B2 (en) * 2016-02-22 2019-12-03 Bank Of America Corporation System to enable contactless access to a transaction terminal using a process data network
CN106383754A (en) * 2016-09-19 2017-02-08 北京众享比特科技有限公司 Database backup and recovery system based on block chain technology, and database backup method based on block chain technology, and database recovery method based on block chain technology
US10754886B2 (en) * 2016-10-05 2020-08-25 International Business Machines Corporation Using multiple natural language classifier to associate a generic query with a structured question type
US10225078B2 (en) * 2017-02-09 2019-03-05 International Business Machines Corporation Managing a database management system using a blockchain database

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017153495A1 (en) * 2016-03-08 2017-09-14 Appii Pty Ltd A system and method for creating a database of independently validated educational and work experience profiles (curricula vitae) using blockchain smart contracts
CN107819829A (en) * 2017-10-17 2018-03-20 上海点融信息科技有限责任公司 Access method, system, block chain node device and the user terminal of block chain
CN108647361A (en) * 2018-05-21 2018-10-12 中国工商银行股份有限公司 A kind of date storage method, apparatus and system based on block chain

Also Published As

Publication number Publication date
CN109492053A (en) 2019-03-19

Similar Documents

Publication Publication Date Title
CN109492053B (en) Method and device for accessing data
US10866791B2 (en) Transforming non-Apex code to Apex code
US20180196665A1 (en) Managing, using, and updating application resources
CN110032599B (en) Data structure reading and updating method and device, and electronic equipment
RU2611966C2 (en) Data enrichment recommending system
US9459862B2 (en) Automated porting of application to mobile infrastructures
US20120158795A1 (en) Entity triggers for materialized view maintenance
CN110032568B (en) Data structure reading and updating method and device, and electronic equipment
CN111125064A (en) Method and device for generating database mode definition statement
CN111126948A (en) Processing method and device for approval process
CN110109983B (en) Method and device for operating Redis database
US20120143866A1 (en) Client Performance Optimization by Delay-Loading Application Files with Cache
US11900269B2 (en) Method and apparatus for managing knowledge base, device and medium
CN108959294B (en) Method and device for accessing search engine
CN116644122A (en) Data transaction processing method, device, computer equipment and storage medium
US11645283B2 (en) Predictive query processing
CN117009397A (en) Data query method, data query device, electronic equipment and storage medium
CN112131257B (en) Data query method and device
CN113760969A (en) Data query method and device based on elastic search
CN113111079A (en) Database execution statement generation method and device
CN113760860B (en) Data reading method and device
US11888937B2 (en) Domain specific provider contracts for core data services
US20230385075A1 (en) Networked Universal Code Package Provider
US20220191104A1 (en) Access management for a multi-endpoint data store
US20230306126A1 (en) Limiting cloud permissions in deployment pipelines

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