技术领域technical field
本申请实施例涉及计算机技术领域,具体涉及用于访问数据的方法和装置。The embodiments of the present application relate to the field of computer technologies, and in particular to methods and devices for accessing data.
背景技术Background technique
区块链是一个去中心化和去信任的分布式数据库,通过共识机制和加密算法可以有效杜绝记录的信息被篡改,做到可追溯。智能合约是以数字形式定义的承诺,包括合约参与方可以在上面执行这些承诺的协议。智能合约于区块链中运行,与外界进行交互,实现区块链数据的读写操作。The blockchain is a decentralized and trustless distributed database. Through the consensus mechanism and encryption algorithm, the recorded information can be effectively prevented from being tampered with and traceable. Smart contracts are promises defined in digital form, including agreements on which the parties to the contract can enforce those promises. The smart contract runs in the blockchain, interacts with the outside world, and realizes the read and write operations of the blockchain data.
受限于区块链开发方式没有被广大开发者熟知,开发者对区块链里面数据的操作方式普遍不太了解,对基于区块链的数据结构设计及开发应用的模式不清晰,使得基于区块链存储的应用开发变得很困难。相关方式中,开发者可以开发、部署及调用智能合约对区块链存储的数据进行读写操作。Due to the fact that the blockchain development method is not well-known to the majority of developers, developers generally do not know much about the operation methods of data in the blockchain, and the data structure design and development and application models based on the blockchain are not clear, which makes the blockchain-based Application development for blockchain storage becomes difficult. In a related way, developers can develop, deploy and call smart contracts to read and write data stored in the blockchain.
发明内容Contents of the invention
本申请实施例提出了用于访问数据的方法和装置。The embodiments of the present application propose a method and an apparatus for accessing data.
第一方面,本申请实施例提供了一种用于访问数据的方法,该方法包括:接收结构化查询语言SQL指令;解析SQL指令,确定SQL指令所指示的数据访问类型;调用目标区块链所运行的智能合约中的、与数据访问类型相匹配的接口,通过接口对目标区块链执行数据访问操作。In the first aspect, the embodiment of the present application provides a method for accessing data. The method includes: receiving a structured query language SQL instruction; parsing the SQL instruction to determine the data access type indicated by the SQL instruction; calling the target block chain The interface in the running smart contract that matches the data access type performs data access operations on the target blockchain through the interface.
在一些实施例中,调用目标区块链所运行的智能合约中的、与数据访问类型相匹配的接口,通过接口对目标区块链执行数据访问操作,包括:响应于确定数据访问类型为只读类型,调用运行在目标区块链的智能合约中的第一目标接口,通过第一目标接口查询目标区块链中的目标数据,其中,目标数据为SQL指令所指示的待查询的数据,第一目标接口用于查询目标区块链中所存储的数据。In some embodiments, calling an interface that matches the data access type in the smart contract run by the target blockchain, and performing a data access operation on the target blockchain through the interface includes: responding to determining that the data access type is only Read type, call the first target interface running in the smart contract of the target blockchain, query the target data in the target blockchain through the first target interface, where the target data is the data to be queried indicated by the SQL command, The first target interface is used to query the data stored in the target blockchain.
在一些实施例中,调用目标区块链所运行的智能合约中的、与数据访问类型相匹配的接口,通过接口对目标区块链执行数据访问操作,包括:响应于确定数据访问类型为读写类型,调用运行在目标区块链的智能合约中的第一目标接口,通过第一目标接口查询目标区块链中的目标数据,其中,目标数据为SQL指令所指示的待更新的数据,第一目标接口用于查询目标区块链中所存储的数据;调用目标区块链所运行的智能合约中的第二目标接口,通过第二目标接口,在目标区块链中存储对目标数据更新后的数据,其中,第二目标接口用于在目标区块链中存储数据。In some embodiments, calling an interface that matches the data access type in the smart contract run by the target blockchain, and performing a data access operation on the target blockchain through the interface includes: responding to determining that the data access type is read Write type, call the first target interface running in the smart contract of the target blockchain, query the target data in the target blockchain through the first target interface, where the target data is the data to be updated indicated by the SQL command, The first target interface is used to query the data stored in the target blockchain; call the second target interface in the smart contract run by the target blockchain, and store the target data in the target blockchain through the second target interface The updated data, wherein the second target interface is used to store data in the target blockchain.
在一些实施例中,该方法还包括:返回执行数据访问操作后的执行结果。In some embodiments, the method further includes: returning an execution result after executing the data access operation.
在一些实施例中,返回执行数据访问操作后的执行结果,包括:响应于确定数据访问类型是只读类型,返回SQL指令所指示的待查询的数据;响应于确定数据访问类型是读写类型,返回用于表征是否成功写入的提示信息。In some embodiments, returning the execution result after executing the data access operation includes: in response to determining that the data access type is a read-only type, returning the data to be queried indicated by the SQL instruction; in response to determining that the data access type is a read-write type , returns the prompt information used to indicate whether the writing is successful.
第二方面,本申请实施例提供了一种用于访问数据的装置,该装置包括:接收单元,被配置成接收结构化查询语言SQL指令;解析单元,被配置成解析SQL指令,确定SQL指令所指示的数据访问类型;访问单元,被配置成调用目标区块链所运行的智能合约中的、与数据访问类型相匹配的接口,利用接口对目标区块链执行数据访问操作。In a second aspect, the embodiment of the present application provides a device for accessing data, the device comprising: a receiving unit configured to receive a structured query language SQL command; a parsing unit configured to parse the SQL command and determine the SQL command The indicated data access type; the access unit is configured to call an interface that matches the data access type in the smart contract run by the target blockchain, and use the interface to perform data access operations on the target blockchain.
在一些实施例中,访问单元,进一步被配置成:响应于确定数据访问类型为只读类型,调用目标区块链所运行的智能合约中的第一目标接口,通过第一目标接口查询目标区块链中的目标数据,其中,目标数据为SQL指令所指示的待查询的数据,第一目标接口用于查询目标区块链中所存储的数据。In some embodiments, the access unit is further configured to: in response to determining that the data access type is read-only, call the first target interface in the smart contract run by the target blockchain, and query the target area through the first target interface The target data in the block chain, wherein the target data is the data to be queried indicated by the SQL command, and the first target interface is used to query the data stored in the target block chain.
在一些实施例中,访问单元,进一步被配置成:响应于确定数据访问类型为读写类型,调用目标区块链所运行的智能合约中的第一目标接口,通过第一目标接口查询目标区块链中的目标数据,其中,目标数据为SQL指令所指示的待更新的数据,第一目标接口用于查询目标区块链中所存储的数据;调用目标区块链所运行的智能合约中的第二目标接口,通过第二目标接口,在目标区块链中存储对目标数据更新后的数据,其中,第二目标接口用于在目标区块链中存储数据。In some embodiments, the access unit is further configured to: in response to determining that the data access type is a read-write type, call the first target interface in the smart contract run by the target blockchain, and query the target area through the first target interface The target data in the block chain, wherein the target data is the data to be updated indicated by the SQL command, and the first target interface is used to query the data stored in the target block chain; The second target interface stores the updated data of the target data in the target block chain through the second target interface, wherein the second target interface is used to store data in the target block chain.
在一些实施例中,该装置还包括:返回单元,被配置成返回执行数据访问操作后的执行结果。In some embodiments, the apparatus further includes: a returning unit configured to return an execution result after the data access operation is executed.
在一些实施例中,返回单元,进一步被配置成:响应于确定数据访问类型是只读类型,返回SQL指令所指示的待查询的数据;响应于确定数据访问类型是读写类型,返回用于表征是否成功写入的提示信息。In some embodiments, the returning unit is further configured to: in response to determining that the data access type is a read-only type, return the data to be queried indicated by the SQL instruction; in response to determining that the data access type is a read-write type, return the A prompt indicating whether the writing is successful.
第三方面,本申请实施例提供了一种电子设备,包括:一个或多个处理器;存储装置,其上存储有一个或多个程序,当一个或多个程序被一个或多个处理器执行,使得一个或多个处理器实现如上述第一方面中任一的方法。In a third aspect, the embodiment of the present application provides an electronic device, including: one or more processors; a storage device, on which one or more programs are stored. Execute, so that one or more processors implement the method according to any one of the first aspect above.
第四方面,本申请实施例提供了一种计算机可读介质,其上存储有计算机程序,该程序被处理器执行时实现如上述第一方面中任一的方法。In a fourth aspect, an embodiment of the present application provides a computer-readable medium, on which a computer program is stored, and when the program is executed by a processor, the method in any one of the above-mentioned first aspects is implemented.
本申请实施例提供的用于访问数据的方法和装置,通过对接收到的SQL指令进行解析,以便调用目标区块链所运行的智能合约中的、与数据访问类型相匹配的接口,从而通过接口对目标区块链执行数据访问操作,由此,可以通过SQL指令实现对目标区块链的访问,提高了对存储于区块链的数据的访问的灵活性。The method and device for accessing data provided by the embodiment of the present application parses the received SQL command so as to call the interface in the smart contract run by the target blockchain that matches the data access type, thereby passing The interface executes a data access operation on the target blockchain, and thus, the access to the target blockchain can be realized through SQL instructions, which improves the flexibility of access to data stored in the blockchain.
附图说明Description of drawings
通过阅读参照以下附图所作的对非限制性实施例所作的详细描述,本申请的其它特征、目的和优点将会变得更明显:Other characteristics, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:
图1是本申请的一个实施例可以应用于其中的示例性系统架构图;FIG. 1 is an exemplary system architecture diagram to which an embodiment of the present application can be applied;
图2是根据本申请的用于访问数据的方法的一个实施例的流程图;Figure 2 is a flowchart of one embodiment of a method for accessing data according to the present application;
图3是根据本申请的用于访问数据的方法的一个应用场景的示意图;FIG. 3 is a schematic diagram of an application scenario of a method for accessing data according to the present application;
图4是根据本申请的用于访问数据的方法的又一个实施例的流程图;FIG. 4 is a flowchart of another embodiment of a method for accessing data according to the present application;
图5是根据本申请的用于访问数据的装置的一个实施例的结构示意图;FIG. 5 is a schematic structural diagram of an embodiment of a device for accessing data according to the present application;
图6是适于用来实现本申请实施例的电子设备的计算机系统的结构示意图。Fig. 6 is a schematic structural diagram of a computer system suitable for implementing the electronic device of the embodiment of the present application.
具体实施方式Detailed ways
下面结合附图和实施例对本申请作进一步的详细说明。可以理解的是,此处所描述的具体实施例仅仅用于解释相关发明,而非对该发明的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与有关发明相关的部分。The application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain related inventions, rather than to limit the invention. It should also be noted that, for the convenience of description, only the parts related to the related invention are shown in the drawings.
需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。下面将参考附图并结合实施例来详细说明本申请。It should be noted that, in the case of no conflict, the embodiments in the present application and the features in the embodiments can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and embodiments.
图1示出了可以应用本申请的用于访问数据的方法或用于访问数据的装置的示例性系统架构100。FIG. 1 shows an exemplary system architecture 100 to which the method for accessing data or the apparatus for accessing data of the present application can be applied.
如图1所示,系统架构100可以包括终端设备101、102、103,网络104和服务器105。网络104用以在终端设备101、102、103和服务器105之间提供通信链路的介质。网络104可以包括各种连接类型,例如有线、无线通信链路或者光纤电缆等等。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 for providing communication links between the terminal devices 101 , 102 , 103 and the server 105 . Network 104 may include various connection types, such as wires, wireless communication links, or fiber optic cables, among others.
用户可以使用终端设备101、102、103通过网络104与服务器105交互,以接收或发送消息等。终端设备101、102、103上可以安装有各种通讯客户端应用,例如语音交互类应用、购物类应用、搜索类应用、即时通信工具、邮箱客户端、社交平台软件等。Users can use terminal devices 101 , 102 , 103 to interact with server 105 via network 104 to receive or send messages and the like. Various communication client applications can be installed on the terminal devices 101, 102, 103, such as voice interaction applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, and the like.
终端设备101、102、103可以是硬件,也可以是软件。当终端设备101、102、103为硬件时,可以是具有显示屏并且支持网络通信的各种电子设备,包括但不限于智能手机、平板电脑、膝上型便携计算机和台式计算机等等。当终端设备101、102、103为软件时,可以安装在上述所列举的电子设备中。其可以实现成多个软件或软件模块(例如用来提供分布式服务),也可以实现成单个软件或软件模块。在此不做具体限定。The terminal devices 101, 102, and 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they may be various electronic devices with display screens and supporting network communication, including but not limited to smart phones, tablet computers, laptop computers and desktop computers, etc. When the terminal devices 101, 102, 103 are software, they can be installed in the electronic devices listed above. It can be implemented as a plurality of software or software modules (for example, to provide distributed services), or as a single software or software module. No specific limitation is made here.
服务器105可以是用于维护目标区块链的服务器,例如存储有该目标区块链的完整记录的节点服务器。节点服务器可以对目标区块链中的数据进行查询,也可以在该目标区块链中写入新的数据等,还可以进行数据的处理(例如进行数据的更新),并将处理结果(利用执行数据访问操作后的执行结果)返回给终端设备。The server 105 may be a server for maintaining the target blockchain, for example, a node server storing a complete record of the target blockchain. The node server can query the data in the target blockchain, write new data in the target blockchain, etc., and can also process the data (for example, update the data), and send the processing results (using The execution result after executing the data access operation) is returned to the terminal device.
需要说明的是,服务器105可以是硬件,也可以是软件。当服务器为硬件时,可以实现成多个服务器组成的分布式服务器集群,也可以实现成单个服务器。当服务器为软件时,可以实现成多个软件或软件模块(例如用来提供分布式服务),也可以实现成单个软件或软件模块。在此不做具体限定。It should be noted that the server 105 may be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster composed of multiple servers, or as a single server. When the server is software, it can be implemented as multiple software or software modules (for example, for providing distributed services), or as a single software or software module. No specific limitation is made here.
需要说明的是,本申请实施例所提供的用于访问数据的方法一般由服务器105执行,相应地,用于访问数据的装置一般设置于服务器105中。It should be noted that the method for accessing data provided in the embodiment of the present application is generally executed by the server 105 , and correspondingly, the device for accessing data is generally set in the server 105 .
应该理解,图1中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器。It should be understood that the numbers of terminal devices, networks and servers in Fig. 1 are only illustrative. According to the implementation needs, there can be any number of terminal devices, networks and servers.
继续参考图2,示出了根据本申请的用于访问数据的方法的一个实施例的流程200。该用于访问数据的方法,包括以下步骤:Continuing to refer to FIG. 2 , a flow 200 of an embodiment of a method for accessing data according to the present application is shown. The method for accessing data includes the following steps:
步骤201,接收SQL指令。Step 201, receiving an SQL command.
在本实施例中,用于访问数据的方法的执行主体(例如图1所示的服务器105)可以利用有线连接或者无线连接方式接收客户端(例如图1所示的终端设备101、102、103)发送的SQL(Structured Query Language,结构化查询语言)指令。此处,SQL指令可以理解为SQL语句。例如,SQL语句“SELECT LastName,FirstName FROM Persons”,用于指示从名为“Persons”的数据表中获取名为"LastName"和"FirstName"的列的内容。In this embodiment, the execution subject of the method for accessing data (such as the server 105 shown in FIG. 1 ) can receive the client (such as the terminal equipment 101, 102, 103 ) to send the SQL (Structured Query Language, structured query language) command. Here, the SQL instruction can be understood as an SQL statement. For example, the SQL statement "SELECT LastName,FirstName FROM Persons" is used to indicate to obtain the contents of the columns named "LastName" and "FirstName" from the data table named "Persons".
需要指出的是,上述无线连接方式可以包括但不限于3G/4G连接、WiFi连接、蓝牙连接、WiMAX连接、Zigbee连接、UWB(ultra wideband)连接、以及其他现在已知或将来开发的无线连接方式。It should be pointed out that the above wireless connection methods may include but not limited to 3G/4G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods known or developed in the future .
实践中,SQL是一种特殊目的的编程语言,是一种数据库查询和程序设计语言,用于存取数据以及查询、更新和管理关系数据库系统。SQL是高级的非过程化编程语言,允许用户在高层数据结构上工作。它不要求用户指定对数据的存放方法,也不需要用户了解具体的数据存放方式,所以具有完全不同底层结构的不同数据库系统,可以使用相同的结构化查询语言作为数据输入与管理的接口。由此,可以使用区块链作为底层的数据存储结构,使用SQL指令对区块链进行访问操作。从而,可以使得开发者采用类似传统数据库的开发方式对区块链存储进行访问,降低区块链应用程序的开发成本。同时,通过将区块链作为数据库的底层存储,实现了数据不可被私自篡改,保障了数据的安全性。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. It does not require the user to specify the data storage method, nor does it require the user to understand the specific data storage method, so different database systems with completely different underlying structures can use the same structured query language as the interface for data input and management. Thus, the blockchain can be used as the underlying data storage structure, and SQL commands can be used to access the blockchain. As a result, developers can use a development method similar to traditional databases to access blockchain storage, reducing the development cost of blockchain applications. At the same time, by using the blockchain as the underlying storage of the database, the data cannot be tampered with privately and the security of the data is guaranteed.
步骤202,解析SQL指令,确定SQL指令所指示的数据访问类型。Step 202, parsing the SQL instruction to determine the data access type indicated by the SQL instruction.
在本实施例中,上述执行主体可以解析上述SQL指令,确定上述SQL指令所指示的数据访问类型。此处,数据访问类型可以包括但不限于只读类型,读写类型等。这里,可以利用各种方式进行上述SQL指令的解析。In this embodiment, the execution subject may parse the SQL instruction to determine the data access type indicated by the SQL instruction. Here, the data access type may include but not limited to read-only type, read-write type, and the like. Here, various methods can be used to analyze the above SQL command.
作为示例,可以使用现有的SQL解析器进行上述SQL指令的解析。As an example, an existing SQL parser may be used to parse the above SQL commands.
作为又一示例,上述执行主体中可以预先设置有SQL指令关键词集合。此外,上述执行主体中可以预先设置有对应关系表,该对应关系表可以用于表征SQL指令关键词与数据访问类型的对应关系。此处,可以首先将步骤201所接收到的SQL指令与预设的SQL指令关键词集合中的SQL指令关键词进行匹配,从而识别出上述SQL指令的关键词。而后,可以在上述对应关系表中查找所匹配出的关键词对应的数据访问类型。As yet another example, the above execution subject may be pre-set with a set of SQL instruction keywords. In addition, a correspondence table may be preset in the execution subject, and the correspondence table may be used to represent the correspondence between SQL instruction keywords and data access types. Here, the SQL instruction received in step 201 may be firstly matched with the SQL instruction keyword in the preset SQL instruction keyword set, so as to identify the keyword of the above SQL instruction. Then, the data access type corresponding to the matched keyword can be searched in the above correspondence table.
需要说明的是,在上述示例中,SQL指令关键词可以是例如“SELECT”、“INSERT”等用于表征操作目的的词。It should be noted that, in the above examples, the keywords of the SQL instruction may be words such as "SELECT" and "INSERT" used to represent the purpose of the operation.
步骤203,调用目标区块链所运行的智能合约中的、与上述数据访问类型相匹配的接口,通过上述接口对目标区块链执行数据访问操作。Step 203, call the interface in the smart contract run by the target blockchain that matches the above-mentioned data access type, and perform data access operations on the target blockchain through the above-mentioned interface.
在本实施例中,上述执行主体中可以调用目标区块链所运行的智能合约中的、与上述数据访问类型相匹配的接口,通过上述接口对目标区块链执行数据访问操作。In this embodiment, the execution subject may call an interface matching the above-mentioned data access type in the smart contract run by the target blockchain, and perform a data access operation on the target blockchain through the above-mentioned interface.
这里,上述执行主体中可以预先存储有数据访问类型与运行在目标区块链的智能合约中的接口的对应关系信息。上述执行主体可以从该对应关系中,直接查询步骤202所确定的数据访问类型相匹配的接口,通过该接口对对目标区块链执行数据访问操作。Here, the execution subject may pre-store the corresponding relationship information between the data access type and the interface running in the smart contract of the target blockchain. From the corresponding relationship, the execution subject can directly query the interface that matches the data access type determined in step 202, and perform data access operations on the target blockchain through the interface.
此处,对于某一个数据访问类型,该数据访问类型对应的接口可以用于对上述目标区块链执行该数据访问类型的数据访问操作。Here, for a certain data access type, the interface corresponding to the data access type can be used to perform the data access operation of the data access type on the above-mentioned target blockchain.
需要说明的是,目标区块链可以是上述执行主体所维护的区块链。上述执行主体中可以存储有该目标区块链的完整记录。实践中,目标区块链可以使用各种现有的区块链。例如支持超级账本(例如Fabric)、以太坊、企业自行开发的区块链等。It should be noted that the target blockchain may be the blockchain maintained by the above-mentioned executive body. A complete record of the target blockchain can be stored in the above execution body. In practice, the target blockchain can use various existing blockchains. For example, it supports hyperbooks (such as Fabric), Ethereum, blockchains developed by enterprises, etc.
实践中,智能合约是以数字形式定义的承诺,包括合约参与方可以在上面执行这些承诺的协议。智能合约于区块链中运行,与外界进行交互,实现区块链数据的读写操作。需要说明的是,上述智能合约是目前广泛研究和应用的公知技术,在此不再赘述。In practice, smart contracts are promises defined in digital form, including agreements on which the parties to the contract can enforce those promises. The smart contract runs in the blockchain, interacts with the outside world, and realizes the read and write operations of the blockchain data. It should be noted that the above-mentioned smart contract is a well-known technology widely researched and applied at present, and will not be repeated here.
在本实施例的一些可选的实现方式中,响应于确定上述数据访问类型为只读类型,上述执行主体可以调用目标区块链所运行的智能合约中的第一目标接口(例如Query(key)接口),通过上述第一目标接口查询上述目标区块链中的目标数据。其中,上述目标数据可以为上述SQL指令所指示的待查询的数据。上述第一目标接口可以用于查询上述目标区块链中所存储的数据。In some optional implementations of this embodiment, in response to determining that the above-mentioned data access type is a read-only type, the above-mentioned execution subject may call the first target interface (such as Query(key ) interface), querying the target data in the target block chain through the first target interface. Wherein, the above-mentioned target data may be the data to be queried indicated by the above-mentioned SQL instruction. The above-mentioned first target interface can be used to query the data stored in the above-mentioned target blockchain.
在本实施例的一些可选的实现方式中,响应于确定上述数据访问类型为读写类型,上述执行主体可以按照如下步骤执行:In some optional implementations of this embodiment, in response to determining that the above-mentioned data access type is a read-write type, the above-mentioned execution subject may execute according to the following steps:
首先,上述执行主体可以调用目标区块链所运行的智能合约中的第一目标接口,以便通过上述第一目标接口查询上述目标区块链中的目标数据。此处,上述目标数据可以为上述SQL指令所指示的待更新的数据。上述第一目标接口可以用于查询上述目标区块链中所存储的数据。First, the execution subject may call the first target interface in the smart contract run by the target blockchain, so as to query the target data in the target blockchain through the first target interface. Here, the above-mentioned target data may be the data to be updated indicated by the above-mentioned SQL instruction. The above-mentioned first target interface can be used to query the data stored in the above-mentioned target blockchain.
第二步,上述执行主体可以调用上述目标区块链所运行的智能合约中的第二目标接口(例如Put(key,value)接口),通过上述第二目标接口,在上述目标区块链中存储对上述目标数据更新后的数据。其中,上述第二目标接口用于在上述目标区块链中存储数据。In the second step, the above-mentioned executive body can call the second target interface (such as the Put(key, value) interface) in the smart contract run by the above-mentioned target blockchain, through the above-mentioned second target interface, in the above-mentioned target blockchain The updated data of the above-mentioned target data is stored. Wherein, the above-mentioned second target interface is used to store data in the above-mentioned target blockchain.
在本实施例的一些可选的实现方式中,上述执行主体在执行数据访问操作之后,可以返回执行上述数据访问操作后的执行结果。具体地,响应于确定上述数据访问类型是只读类型,可以返回上述SQL指令所指示的待查询的数据;响应于确定上述数据访问类型是读写类型,可以返回用于表征是否成功写入的提示信息。作为示例,若数据访问操作是只读查询某一个或多个数据,则上述执行主体可以返回所查询到的该数据或数据集合。作为又一示例,若数据访问操作是写入某个数据,则上述执行主体可以返回用于指示是否成功写入的提示信息。In some optional implementation manners of this embodiment, after performing the data access operation, the execution subject may return an execution result after performing the data access operation. Specifically, in response to determining that the above-mentioned data access type is a read-only type, the data to be queried indicated by the above-mentioned SQL instruction may be returned; in response to determining that the above-mentioned data access type is a read-write type, it may be returned. Prompt information. As an example, if the data access operation is a read-only query for one or more pieces of data, the execution subject may return the queried data or data set. As yet another example, if the data access operation is to write certain data, the execution subject may return prompt information indicating whether the writing is successful.
继续参见图3,图3是根据本实施例的用于访问数据的方法的应用场景的一个示意图。在图3的应用场景中,用户首先利用终端设备301发送了SQL指令至区块链系统303。区块链系统303中可以包含多个节点服务器。各节点服务器可以用于维护目标区块链,例如,存储有该目标区块链的完整记录。该目标区块链可以运行有智能合约。Continue referring to FIG. 3 , which is a schematic diagram of an application scenario of the method for accessing data according to this embodiment. In the application scenario of FIG. 3 , the user first uses the terminal device 301 to send an SQL command to the blockchain system 303 . The blockchain system 303 may contain multiple node servers. Each node server can be used to maintain the target blockchain, for example, a complete record of the target blockchain is stored. The target blockchain can run smart contracts.
在发送SQL指令之后,区块链系统303中的任一节点服务器可以对上述SQL指令进行解析,从而确定上述SQL指令所指示的数据访问类型。而后,该节点服务器可以调用运行在目标区块链的智能合约中的、与上述数据访问类型相匹配的接口,通过上述接口对上述目标区块链执行数据访问操作。在这里,区块链系统可以理解为由SQL接口层、SQL适配层、区块链存储层这三层结构所构成。其中,SQL接口层可以支持标准SQL、JDBC(Java DataBaseConnectivity,java数据库连接)、ODBC(Open Database Connectivity,开放数据库连接)等常用的SQL访问服务,以及SQL语法检查。SQL适配层可以将上层(即SQL接口层)接收的SQL命令通过转换为智能合约指令,对区块链账本数据进行操作。区块链存储层可以对数据进行存储。After sending the SQL command, any node server in the blockchain system 303 can analyze the above SQL command to determine the data access type indicated by the above SQL command. Then, the node server can call an interface running in the smart contract of the target blockchain that matches the above-mentioned data access type, and perform data access operations on the above-mentioned target blockchain through the above-mentioned interface. Here, the blockchain system can be understood as consisting of a three-layer structure of SQL interface layer, SQL adaptation layer, and blockchain storage layer. Among them, the SQL interface layer can support common SQL access services such as standard SQL, JDBC (Java DataBaseConnectivity, java database connection), ODBC (Open Database Connectivity, open database connection), and SQL syntax checking. The SQL adaptation layer can convert the SQL commands received by the upper layer (that is, the SQL interface layer) into smart contract instructions to operate on the blockchain ledger data. The blockchain storage layer can store data.
本申请的上述实施例提供的方法,通过对接收到的SQL指令进行解析,以便调用目标区块链所运行的智能合约中的、与上述数据访问类型相匹配的接口,从而通过上述接口对上述目标区块链执行数据访问操作,由此,可以通过SQL指令实现对目标区块链的访问,提高了对存储于区块链的数据的访问的灵活性。由于区块链开发方式没有被广大开发者熟知,开发者对区块链里面数据的操作方式普遍不太了解,对基于区块链的数据结构设计及开发应用的模式不清晰,使得基于区块链存储的应用开发变得很困难。通过本申请的上述实施例提供的方法,可以对开发者提供利用SQL指令的访问方式,降低了区块链存储的使用门槛。同时,传统数据库只需要少量修改便可以实现将数据迁移至区块链中。使得上链业务可以运用上区块链去中心化、防篡改等特性。The method provided by the above-mentioned embodiments of the present application parses the received SQL command so as to call the interface in the smart contract run by the target blockchain that matches the above-mentioned data access type, thereby through the above-mentioned interface to the above-mentioned The target blockchain executes the data access operation, thus, the access to the target blockchain can be realized through the SQL instruction, which improves the flexibility of accessing the data stored in the blockchain. Since the blockchain development method is not well known by the majority of developers, developers generally do not know much about the operation of data in the blockchain, and the data structure design and development and application models based on the blockchain are not clear, making the blockchain-based The application development of chain storage becomes very difficult. Through the methods provided by the above-mentioned embodiments of the present application, developers can be provided with an access method using SQL commands, which lowers the threshold for using blockchain storage. At the same time, traditional databases only need a small amount of modification to migrate data to the blockchain. It enables the on-chain business to use the decentralization and anti-tampering features of the blockchain.
进一步参考图4,其示出了用于访问数据的方法的又一个实施例的流程400。该用于访问数据的方法的流程400,包括以下步骤:Further referring to FIG. 4 , it shows a flow 400 of still another embodiment of a method for accessing data. The flow 400 of the method for accessing data includes the following steps:
步骤401,接收SQL指令。Step 401, receiving an SQL command.
在本实施例中,用于访问数据的方法的执行主体(例如图1所示的服务器105)可以利用有线连接或者无线连接方式接收客户端(例如图1所示的终端设备101、102、103)发送的SQL(Structured Query Language,结构化查询语言)指令。此处,SQL指令可以理解为SQL语句。例如,SQL语句“SELECT LastName,FirstName FROM Persons”,用于指示从名为“Persons”的数据表中获取名为"LastName"和"FirstName"的列的内容。In this embodiment, the execution subject of the method for accessing data (such as the server 105 shown in FIG. 1 ) can receive the client (such as the terminal equipment 101, 102, 103 ) to send the SQL (Structured Query Language, structured query language) command. Here, the SQL instruction can be understood as an SQL statement. For example, the SQL statement "SELECT LastName,FirstName FROM Persons" is used to indicate to obtain the contents of the columns named "LastName" and "FirstName" from the data table named "Persons".
步骤402,解析SQL指令,确定SQL指令所指示的数据访问类型。Step 402, analyzing the SQL instruction to determine the data access type indicated by the SQL instruction.
在本实施例中,上述执行主体可以解析上述SQL指令,确定上述SQL指令所指示的数据访问类型。此处,数据访问类型可以包括但不限于只读类型,读写类型等。这里,解析SQL指令的操作与步骤201的操作基本相同,此处不再赘述。In this embodiment, the execution subject may parse the SQL instruction to determine the data access type indicated by the SQL instruction. Here, the data access type may include but not limited to read-only type, read-write type, and the like. Here, the operation of parsing the SQL instruction is basically the same as the operation of step 201, and will not be repeated here.
步骤403,响应于确定数据访问类型为只读类型,调用目标区块链所运行的智能合约中的第一目标接口,通过第一目标接口查询目标区块链中的目标数据。Step 403, in response to determining that the data access type is read-only, call the first target interface in the smart contract run by the target blockchain, and query the target data in the target blockchain through the first target interface.
在本实施例中,响应于确定上述数据访问类型为只读类型,上述执行主体可以调用目标区块链所运行的智能合约中的第一目标接口(例如Query(key)接口),通过上述第一目标接口查询上述目标区块链中的目标数据。其中,上述目标数据可以为上述SQL指令所指示的待查询的数据。上述第一目标接口可以用于查询上述目标区块链中所存储的数据。In this embodiment, in response to determining that the above-mentioned data access type is read-only, the above-mentioned executive body can call the first target interface (such as the Query (key) interface) in the smart contract run by the target blockchain, through the above-mentioned first A target interface queries the target data in the target blockchain. Wherein, the above-mentioned target data may be the data to be queried indicated by the above-mentioned SQL instruction. The above-mentioned first target interface can be used to query the data stored in the above-mentioned target blockchain.
步骤404,响应于确定数据访问类型为读写类型,调用目标区块链所运行的智能合约中的第一目标接口,通过第一目标接口查询目标区块链中的目标数据。Step 404, in response to determining that the data access type is the read-write type, call the first target interface in the smart contract run by the target blockchain, and query the target data in the target blockchain through the first target interface.
在本实施例中,响应于确定上述数据访问类型为读写类型,上述执行主体可以调用目标区块链所运行的智能合约中的第一目标接口,通过上述第一目标接口查询上述目标区块链中的目标数据。此处,上述目标数据可以为上述SQL指令所指示的待更新的数据。上述第一目标接口可以用于查询上述目标区块链中所存储的数据。In this embodiment, in response to determining that the above-mentioned data access type is a read-write type, the above-mentioned executive body can call the first target interface in the smart contract run by the target blockchain, and query the above-mentioned target block through the above-mentioned first target interface Target data in the chain. Here, the above-mentioned target data may be the data to be updated indicated by the above-mentioned SQL instruction. The above-mentioned first target interface can be used to query the data stored in the above-mentioned target blockchain.
步骤405,调用目标区块链所运行的智能合约中的第二目标接口,通过第二目标接口,在目标区块链中存储对目标数据更新后的数据。Step 405, call the second target interface in the smart contract run by the target blockchain, and store the updated data of the target data in the target blockchain through the second target interface.
在本实施例中,上述执行主体可以调用目标区块链所运行的智能合约中的第二目标接口(例如Put(key,value)接口),通过上述第二目标接口,在上述目标区块链中存储对上述目标数据更新后的数据。其中,上述第二目标接口用于在上述目标区块链中存储数据。In this embodiment, the above-mentioned execution subject can call the second target interface (such as Put(key, value) interface) in the smart contract run by the target blockchain, through the above-mentioned second target interface, in the above-mentioned target blockchain The updated data of the above target data is stored in . Wherein, the above-mentioned second target interface is used to store data in the above-mentioned target blockchain.
步骤406,返回执行数据访问操作后的执行结果。Step 406, return the execution result after executing the data access operation.
在本实施例中,上述执行主体在执行数据访问操作之后,可以返回执行上述数据访问操作后的执行结果。作为示例,若数据访问操作是只读查询某个数据,则上述执行主体可以返回所查询到的该数据。作为又一示例,若数据访问操作是写入某个数据,则上述执行主体可以返回用于指示是否成功写入的提示信息。In this embodiment, after executing the data access operation, the execution subject may return an execution result after executing the data access operation. As an example, if the data access operation is a read-only query for certain data, the execution subject may return the queried data. As yet another example, if the data access operation is to write certain data, the execution subject may return prompt information indicating whether the writing is successful.
从图4中可以看出,与图2对应的实施例相比,本实施例中的用于访问数据的方法的流程400涉及了针对只读类型、读写类型的SQL指令进行区块链的数据访问的操作。由此,可以通过对区块链存储访问的智能合约进行适配,对开发者提供利用SQL指令的访问方式,降低了区块链存储的使用门槛。同时,传统数据库只需要少量修改便可以实现将数据迁移至区块链中。使得上链业务可以运用上区块链去中心化、防篡改等特性。It can be seen from FIG. 4 that, compared with the embodiment corresponding to FIG. 2 , the flow 400 of the method for accessing data in this embodiment involves performing block chaining for read-only and read-write SQL instructions. Operations for data access. Therefore, by adapting the smart contract for blockchain storage access, developers can be provided with an access method using SQL commands, which lowers the threshold for using blockchain storage. At the same time, traditional databases only need a small amount of modification to migrate data to the blockchain. It enables the on-chain business to use the decentralization and anti-tampering features of the blockchain.
进一步参考图5,作为对上述各图所示方法的实现,本申请提供了一种用于访问数据的装置的一个实施例,该装置实施例与图2所示的方法实施例相对应,该装置具体可以应用于各种电子设备中。Further referring to FIG. 5 , as an implementation of the methods shown in the above figures, the present application provides an embodiment of a device for accessing data, which corresponds to the method embodiment shown in FIG. 2 , the The device can be specifically applied to various electronic devices.
如图5所示,本实施例所述的用于访问数据的装置500包括:接收单元501,被配置成接收结构化查询语言SQL指令;解析单元502,被配置成解析上述SQL指令,确定上述SQL指令所指示的数据访问类型;访问单元503,被配置成调用目标区块链所运行的智能合约中的、与上述数据访问类型相匹配的接口,利用上述接口对上述目标区块链执行数据访问操作。As shown in FIG. 5 , the device 500 for accessing data described in this embodiment includes: a receiving unit 501 configured to receive a structured query language SQL command; a parsing unit 502 configured to parse the above SQL command to determine the above The type of data access indicated by the SQL instruction; the access unit 503 is configured to call an interface that matches the above-mentioned data access type in the smart contract run by the target blockchain, and use the above-mentioned interface to perform data execution on the above-mentioned target blockchain. access operations.
在本实施例的一些可选的实现方式中,上述访问单元503可以进一步被配置成:响应于确定上述数据访问类型为只读类型,调用目标区块链所运行的智能合约中的第一目标接口,通过上述第一目标接口查询上述目标区块链中的目标数据,其中,上述目标数据为上述SQL指令所指示的待查询的数据,上述第一目标接口用于查询上述目标区块链中所存储的数据。In some optional implementations of this embodiment, the above-mentioned access unit 503 may be further configured to: in response to determining that the above-mentioned data access type is a read-only type, call the first target in the smart contract run by the target blockchain interface, querying the target data in the target blockchain through the first target interface, wherein the target data is the data to be queried indicated by the SQL command, and the first target interface is used to query the target data in the target blockchain the stored data.
在本实施例的一些可选的实现方式中,上述访问单元503可以进一步被配置成:响应于确定上述数据访问类型为读写类型,调用目标区块链所运行的智能合约中的第一目标接口,通过上述第一目标接口查询上述目标区块链中的目标数据,其中,上述目标数据为上述SQL指令所指示的待更新的数据,上述第一目标接口用于查询上述目标区块链中所存储的数据;调用目标区块链所运行的智能合约中的第二目标接口,通过上述第二目标接口,在上述目标区块链中存储对上述目标数据更新后的数据,其中,上述第二目标接口用于在上述目标区块链中存储数据。In some optional implementations of this embodiment, the above-mentioned access unit 503 may be further configured to: in response to determining that the above-mentioned data access type is a read-write type, call the first target in the smart contract run by the target blockchain interface, querying the target data in the target blockchain through the first target interface, wherein the target data is the data to be updated indicated by the SQL command, and the first target interface is used to query the target data in the target blockchain Stored data; call the second target interface in the smart contract run by the target block chain, and store the updated data of the above target data in the target block chain through the above second target interface, wherein the above-mentioned first The second target interface is used to store data in the above target blockchain.
在本实施例的一些可选的实现方式中,该装置还可以包括返回单元(图中未示出)。其中,上述返回单元可以被配置成返回执行上述数据访问操作后的执行结果。In some optional implementation manners of this embodiment, the device may further include a return unit (not shown in the figure). Wherein, the above returning unit may be configured to return an execution result after executing the above data access operation.
在一些实施例中,所述返回单元可以进一步被配置成:响应于确定数据访问类型是只读类型,返回SQL指令所指示的待查询的数据;响应于确定数据访问类型是读写类型,返回用于表征是否成功写入的提示信息。In some embodiments, the returning unit may be further configured to: in response to determining that the data access type is a read-only type, return the data to be queried indicated by the SQL instruction; in response to determining that the data access type is a read-write type, return The prompt information used to indicate whether the writing is successful.
本申请的上述实施例提供的装置,通过解析单元502对接收单元501接收到的SQL指令进行解析,以便访问单元503调用目标区块链所运行的智能合约中的、与上述数据访问类型相匹配的接口,从而通过上述接口对上述目标区块链执行数据访问操作,由此,可以通过SQL指令实现对目标区块链的访问,提高了对存储于区块链的数据的访问的灵活性。由于区块链开发方式没有被广大开发者熟知,开发者对区块链里面数据的操作方式普遍不太了解,对基于区块链的数据结构设计及开发应用的模式不清晰,使得基于区块链存储的应用开发变得很困难。通过本申请的上述实施例提供的方法,可以对开发者提供利用SQL指令的访问方式,降低了区块链存储的使用门槛。同时,传统数据库只需要少量修改便可以实现将数据迁移至区块链中。使得上链业务可以运用上区块链去中心化、防篡改等特性。The device provided by the above-mentioned embodiments of the present application uses the parsing unit 502 to parse the SQL command received by the receiving unit 501, so that the access unit 503 calls the smart contract running on the target blockchain that matches the above-mentioned data access type. Interface, so as to perform data access operations on the above-mentioned target blockchain through the above-mentioned interface, thus, the access to the target blockchain can be realized through SQL instructions, and the flexibility of access to the data stored in the blockchain is improved. Since the blockchain development method is not well known by the majority of developers, developers generally do not know much about the operation of data in the blockchain, and the data structure design and development and application models based on the blockchain are not clear, making the blockchain-based The application development of chain storage becomes very difficult. Through the methods provided by the above-mentioned embodiments of the present application, developers can be provided with an access method using SQL commands, which lowers the threshold for using blockchain storage. At the same time, traditional databases only need a small amount of modification to migrate data to the blockchain. It enables the on-chain business to use the decentralization and anti-tampering features of the blockchain.
下面参考图6,其示出了适于用来实现本申请实施例的电子设备的计算机系统600的结构示意图。图6示出的电子设备仅仅是一个示例,不应对本申请实施例的功能和使用范围带来任何限制。Referring now to FIG. 6 , it shows a schematic structural diagram of a computer system 600 suitable for implementing the electronic device of the embodiment of the present application. The electronic device shown in FIG. 6 is only an example, and should not limit the functions and scope of use of this embodiment of the present application.
如图6所示,计算机系统600包括中央处理单元(CPU)601,其可以根据存储在只读存储器(ROM)602中的程序或者从存储部分608加载到随机访问存储器(RAM)603中的程序而执行各种适当的动作和处理。在RAM 603中,还存储有系统600操作所需的各种程序和数据。CPU 601、ROM 602以及RAM 603通过总线604彼此相连。输入/输出(I/O)接口605也连接至总线604。As shown in FIG. 6 , a computer system 600 includes a central processing unit (CPU) 601 that can be programmed 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 Instead, various appropriate actions and processes are performed. In the RAM 603, various programs and data necessary for the operation of the system 600 are also stored. The CPU 601 , ROM 602 , and RAM 603 are connected to each other via a bus 604 . An input/output (I/O) interface 605 is also connected to the bus 604 .
以下部件连接至I/O接口605:包括键盘、鼠标等的输入部分606;包括诸如阴极射线管(CRT)、液晶显示器(LCD)等以及扬声器等的输出部分607;包括硬盘等的存储部分608;以及包括诸如LAN卡、调制解调器等的网络接口卡的通信部分609。通信部分609经由诸如因特网的网络执行通信处理。驱动器610也根据需要连接至I/O接口605。可拆卸介质611,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器610上,以便于从其上读出的计算机程序根据需要被安装入存储部分608。The following components are connected to the I/O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage section 608 including a hard disk, etc. 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. A drive 610 is also connected to the I/O interface 605 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is mounted on the drive 610 as necessary so that a computer program read therefrom is installed into the storage section 608 as necessary.
特别地,根据本公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分609从网络上被下载和安装,和/或从可拆卸介质611被安装。在该计算机程序被中央处理单元(CPU)601执行时,执行本申请的方法中限定的上述功能。需要说明的是,本申请所述的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本申请中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本申请中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、电线、光缆、RF等等,或者上述的任意合适的组合。In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product, which includes a computer program carried on a computer-readable medium, where the computer program includes program codes for executing the methods shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via communication portion 609 and/or installed from removable media 611 . When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the method of the present application are performed. It should be noted that the computer-readable medium described in this application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, electrical connections with one or more wires, portable computer diskettes, hard disks, random access memory (RAM), read-only memory (ROM), erasable Programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above. In this application, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, however, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, in which computer-readable program codes are carried. Such propagated data signals may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction 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, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
附图中的流程图和框图,图示了按照本申请各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,该模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowchart 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 a flowchart or block diagram may represent a module, program segment, or portion of code that contains one or more logical functions for implementing specified executable instructions. 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 they may sometimes be executed in the reverse order, depending upon the functionality involved. It should also be noted that each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations, can be implemented by a dedicated hardware-based system that performs the specified functions or operations , or may be implemented by a combination of dedicated hardware and computer instructions.
描述于本申请实施例中所涉及到的单元可以通过软件的方式实现,也可以通过硬件的方式来实现。所描述的单元也可以设置在处理器中,例如,可以描述为:一种处理器包括接收单元、解析单元和访问单元。其中,这些单元的名称在某种情况下并不构成对该单元本身的限定,例如,接收单元还可以被描述为“接收接收结构化查询语言SQL指令的单元”。The units involved in the embodiments described in the present application may be implemented by means of software or by means of hardware. The described units may also be set in a processor, for example, it may be described as: a processor includes a receiving unit, a parsing unit, and an accessing unit. Wherein, the names of these units do not limit the unit itself under certain circumstances, for example, the receiving unit may also be described as “a unit that receives and receives structured query language SQL instructions”.
作为另一方面,本申请还提供了一种计算机可读介质,该计算机可读介质可以是上述实施例中描述的装置中所包含的;也可以是单独存在,而未装配入该装置中。上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被该装置执行时,使得该装置:接收结构化查询语言SQL指令;解析该SQL指令,确定该SQL指令所指示的数据访问类型;调用运行在目标区块链的智能合约中的、与该数据访问类型相匹配的接口,通过该接口对该目标区块链执行数据访问操作。As another aspect, the present application also provides a computer-readable medium. The computer-readable medium may be included in the device described in the above embodiments, or it may exist independently without being assembled into the device. The above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by the device, the device: receives a structured query language SQL instruction; parses the SQL instruction, and determines the SQL instruction indicated Data access type; call the interface running in the smart contract of the target blockchain that matches the data access type, and perform data access operations on the target blockchain through this interface.
以上描述仅为本申请的较佳实施例以及对所运用技术原理的说明。本领域技术人员应当理解,本申请中所涉及的发明范围,并不限于上述技术特征的特定组合而成的技术方案,同时也应涵盖在不脱离上述发明构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本申请中公开的(但不限于)具有类似功能的技术特征进行互相替换而形成的技术方案。The above description is only a preferred embodiment of the present application and an illustration of the applied technical principle. Those skilled in the art should understand that the scope of the invention involved in this application is not limited to the technical solution formed by the specific combination of the above-mentioned technical features, and should also cover the technical solution formed by the above-mentioned technical features or Other technical solutions formed by any combination of equivalent features. For example, a technical solution formed by replacing the above-mentioned features with technical features with similar functions disclosed in (but not limited to) this application.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201811324189.4ACN109492053B (en) | 2018-11-08 | 2018-11-08 | Method and apparatus for accessing data |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201811324189.4ACN109492053B (en) | 2018-11-08 | 2018-11-08 | Method and apparatus for accessing data |
| Publication Number | Publication Date |
|---|---|
| CN109492053A CN109492053A (en) | 2019-03-19 |
| CN109492053Btrue CN109492053B (en) | 2023-07-18 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201811324189.4AActiveCN109492053B (en) | 2018-11-08 | 2018-11-08 | Method and apparatus for accessing data |
| Country | Link |
|---|---|
| CN (1) | CN109492053B (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110177079B (en)* | 2019-04-17 | 2021-10-15 | 北京百度网讯科技有限公司 | Smart contract calling system and calling method |
| 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 |
| CN113836175B (en)* | 2020-06-24 | 2024-08-09 | 浙江宇视科技有限公司 | Data access method, device, equipment and storage medium |
| CN112306645B (en) | 2020-12-24 | 2021-05-04 | 北京百度网讯科技有限公司 | Transaction processing method, apparatus, device and medium for Ethereum virtual machine |
| CN113157723B (en)* | 2021-04-06 | 2022-06-03 | 福州大学 | SQL access method for Hyperridge Fabric |
| 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 |
| 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 |
| 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 |
| US10142312B2 (en)* | 2016-02-22 | 2018-11-27 | Bank Of America Corporation | System for establishing secure access for users in 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 |
| 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 |
| Publication number | Publication date |
|---|---|
| CN109492053A (en) | 2019-03-19 |
| Publication | Publication Date | Title |
|---|---|---|
| CN109492053B (en) | Method and apparatus for accessing data | |
| US10866791B2 (en) | Transforming non-Apex code to Apex code | |
| US10803029B2 (en) | Generating javascript object notation (JSON) schema from JSON payloads | |
| US10977011B2 (en) | Structured development for web application frameworks | |
| US10248711B2 (en) | Representation of time-sensitive and space-sensitive profile information | |
| US8244780B1 (en) | Parameter oriented automated database command | |
| US11687568B2 (en) | Data catalog system for generating synthetic datasets | |
| US10261808B2 (en) | Access operation with dynamic linking and access of data within plural data sources | |
| US11275806B2 (en) | Dynamic materialization of feeds for enabling access of the feed in an online social network | |
| CN103400579A (en) | Voice recognition system and construction method | |
| CN113688151B (en) | Data access method, device, system, equipment and medium based on virtual database | |
| CN108959294B (en) | Method and device for accessing search engine | |
| CN112970011A (en) | Recording pedigrees in query optimization | |
| JP2024505238A (en) | Data processing system with operations on logical dataset groups | |
| CN114356964A (en) | Data lineage construction method, device, storage medium and electronic device | |
| CN113760947B (en) | A data platform, data processing method, device, equipment and storage medium | |
| CN117009397A (en) | Data query method, data query device, electronic equipment and storage medium | |
| US10289620B1 (en) | Reporting and data governance management | |
| US12117999B2 (en) | Masking shard operations in distributed database systems | |
| US20220004531A1 (en) | In-memory data structure for data access | |
| US20170220656A1 (en) | Information Access System | |
| US10318524B2 (en) | Reporting and data governance management | |
| US12072882B2 (en) | Database query processing | |
| US11888937B2 (en) | Domain specific provider contracts for core data services | |
| US12430365B2 (en) | Lakehouse metadata tag creation method, lakehouse metadata tag query method and electronic device |
| 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 |