[go: up one dir, main page]

CN116755685A - Configuration method, device and data query method of data interface - Google Patents

Configuration method, device and data query method of data interface Download PDF

Info

Publication number
CN116755685A
CN116755685A CN202310453518.XA CN202310453518A CN116755685A CN 116755685 A CN116755685 A CN 116755685A CN 202310453518 A CN202310453518 A CN 202310453518A CN 116755685 A CN116755685 A CN 116755685A
Authority
CN
China
Prior art keywords
query
data
data interface
template
interface
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.)
Pending
Application number
CN202310453518.XA
Other languages
Chinese (zh)
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.)
Chongqing Selis Phoenix Intelligent Innovation Technology Co ltd
Original Assignee
Chengdu Seres 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 Chengdu Seres Technology Co Ltd filed Critical Chengdu Seres Technology Co Ltd
Priority to CN202310453518.XA priority Critical patent/CN116755685A/en
Publication of CN116755685A publication Critical patent/CN116755685A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/36Software reuse
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/33Intelligent editors

Landscapes

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

Abstract

The embodiment of the application provides a data interface configuration method, a data interface configuration device and a data query method, which can enable an developer to quickly configure and issue a data interface for querying target data only with basic development experience. The configuration method of the data interface comprises the following steps: responding to the creation operation of the data interface, and creating a corresponding data source for the data interface; responding to a first configuration operation for the data interface, and determining a database driver, a database connection and a query template corresponding to the data interface according to the first configuration operation, wherein the query template is a precompiled data source query instruction using a placeholder to replace a request parameter; responding to a second configuration operation for the data interface, creating unique interface information corresponding to the data interface according to the second configuration operation, and determining the mapping relation between the unique interface information and the database driver, the database connection and the query template; responsive to a docking operation for the data interface, the data interface is published to the business system to provide a data query.

Description

一种数据接口的配置方法、装置及数据查询方法Configuration method, device and data query method of data interface

【技术领域】【Technical field】

本申请实施例涉及数据库技术领域,尤其涉及一种数据接口的配置方法、装置及数据查询方法。The embodiments of the present application relate to the field of database technology, and in particular, to a data interface configuration method, device and data query method.

【背景技术】【Background technique】

目前,随着大数据技术的高速发展,很多企业、机构都将内部使用的业务系统与各种大数据平台提供的数据库产品接驳,并利用其提供的数据接口对业务系统产生的数据进行整合、管理。但在开发这些数据库产品的数据接口时,往往需要开发者具有较高的结构化查询语言(Structured Query Language,简称SQL)和其它编程语言的开发经验,且开发数据接口的时间较长、开发成本较高。At present, with the rapid development of big data technology, many enterprises and institutions are connecting their internal business systems with database products provided by various big data platforms, and using the data interfaces provided by them to integrate the data generated by the business systems. ,manage. However, when developing data interfaces for these database products, developers often need to have high development experience in Structured Query Language (SQL) and other programming languages, and the development of data interfaces takes a long time and costs a lot. higher.

【发明内容】[Content of the invention]

本申请实施例提供了一种数据接口的配置方法、数据查询方法及装置,能让开发者只需对结构化查询语言和编程语言具有基本开发经验即可快速配置、发布面向用户的数据接口,使用户通过使用该数据接口的业务系统便捷地查询出所需的目标数据,降低数据接口的开发时间和成本。The embodiments of this application provide a data interface configuration method, data query method and device, which enable developers to quickly configure and publish user-oriented data interfaces only with basic development experience in structured query languages and programming languages. This allows users to easily query the required target data through the business system using the data interface, reducing the development time and cost of the data interface.

第一方面,本申请实施例提供了一种数据接口的配置方法,所述方法包括:In a first aspect, embodiments of the present application provide a method for configuring a data interface. The method includes:

响应对于数据接口的创建操作,为所述数据接口创建对应的数据源;In response to the creation operation of the data interface, create a corresponding data source for the data interface;

响应对于所述数据接口的第一配置操作,根据所述第一配置操作确定所述数据接口对应的数据库驱动、数据库连接与查询模板,所述查询模板为使用占位符替换请求参数的预编译数据源查询指令;In response to the first configuration operation for the data interface, determine the database driver, database connection and query template corresponding to the data interface according to the first configuration operation. The query template is a pre-compiled request parameter using placeholders. Data source query instructions;

响应对于所述数据接口的第二配置操作,根据所述第二配置操作创建所述数据接口对应的唯一接口信息,并确定所述唯一接口信息与所述数据库驱动、所述数据库连接以及所述查询模板之间的映射关系;In response to the second configuration operation for the data interface, create unique interface information corresponding to the data interface according to the second configuration operation, and determine whether the unique interface information is consistent with the database driver, the database connection, and the Query the mapping relationship between templates;

响应对于所述数据接口的对接操作,将所述数据接口发布至业务系统以提供数据查询。In response to the docking operation on the data interface, the data interface is published to the business system to provide data query.

本申请实施例中,开发者在创建数据接口所连接的数据源后,即可通过相关操作直接指定数据接口对应的数据库驱动、数据库连接以及预编译的查询模板,以及建立这些信息与数据接口的唯一接口信息之间的映射关系,从而快速完成数据接口的开发,无需再对数据接口的底层代码架构进行设计与编程,降低开发时间与开发成本。In the embodiment of this application, after creating the data source connected to the data interface, the developer can directly specify the database driver, database connection and precompiled query template corresponding to the data interface through relevant operations, as well as establish the information and data interface. The mapping relationship between unique interface information can quickly complete the development of data interfaces. There is no need to design and program the underlying code architecture of the data interface, reducing development time and development costs.

可选的,所述响应对于所述数据接口的对接操作,将所述数据接口发布至业务系统以提供数据查询之前,所述方法还包括:Optionally, before the response is to the docking operation of the data interface and the data interface is released to the business system to provide data query, the method further includes:

响应对于所述数据接口的前置检查配置操作,根据所述前置检查配置操作生成必填参数规则,并将所述必填参数规则与所述数据接口进行对接,所述必填参数规则用于检查用户发送给所述数据接口的请求参数中是否包含能够查询出目标数据的全部参数。In response to the pre-check configuration operation for the data interface, generate a required parameter rule according to the pre-check configuration operation, and connect the required parameter rule with the data interface. The required parameter rule is used To check whether the request parameters sent by the user to the data interface include all parameters that can query the target data.

本申请实施例中,通过制定必填参数规则来检查用户在查询目标数据时,所填写的请求参数中是否包含定位出目标数据所必需的全部参数,若不包含这些参数则返回错误信息,提醒用户参数填写不合法,从而让用户能够发现请求参数的填写问题并对其进行修改。In the embodiment of this application, the required parameter rules are formulated to check whether the request parameters filled in by the user when querying the target data include all the parameters necessary to locate the target data. If these parameters are not included, an error message will be returned to remind The filling in of user parameters is illegal, allowing users to discover problems with filling in request parameters and modify them.

可选的,所述数据源为关系型数据库,所述响应对于所述数据接口的第一配置操作,根据所述第一配置操作确定所述数据接口对应的数据库驱动、数据库连接与查询模板之前,所述方法还包括:Optionally, the data source is a relational database, and the response is to the first configuration operation of the data interface before determining the database driver, database connection and query template corresponding to the data interface according to the first configuration operation. , the method also includes:

响应对于所述查询模板的模板引擎设置操作,确定渲染基于关系型数据库的所述查询模板需要使用的模板引擎;In response to the template engine setting operation for the query template, determine the template engine that needs to be used to render the query template based on the relational database;

响应对于所述查询模板的编辑操作,将预编译的结构化查询语言指令、至少一个占位符以及用于描述所述结构化查询语言指令的文本渲染方式的模板引擎指令生成为基于关系型数据库的所述查询模板。In response to an editing operation on the query template, generate a precompiled structured query language instruction, at least one placeholder, and a template engine instruction for describing a text rendering method of the structured query language instruction into a relational database-based The query template.

本申请实施例中,可以通过指定查询模板需要使用的模板引擎,并使用结构化查询语言、对应的模板引擎指令语言以及至少一个预先规定的占位符来编写用于渲染结构化查询语言指令、检索关系型数据库的查询模板,从而使开发者根据数据源不同和用户的使用需求来进行定制化配置,增强数据接口开发的灵活性,同时也节省了对每种用户需求都进行单独配置的开发时间。In the embodiment of this application, you can specify the template engine that needs to be used for the query template, and use the structured query language, the corresponding template engine instruction language, and at least one predetermined placeholder to write instructions for rendering the structured query language. Retrieve query templates of relational databases, allowing developers to customize configurations based on different data sources and user needs, enhancing the flexibility of data interface development and saving the development effort of separately configuring each user requirement. time.

可选的,所述数据源为非关系型数据库,所述响应对于所述数据接口的第一配置操作,根据所述第一配置操作确定所述数据接口对应的数据库驱动、数据库连接与查询模板之前,所述方法还包括:Optionally, the data source is a non-relational database, and the response to the first configuration operation of the data interface determines the database driver, database connection and query template corresponding to the data interface according to the first configuration operation. Previously, the method also included:

响应对于所述查询模板的模板引擎设置操作,确定渲染基于非关系型数据库的所述查询模板需要使用的模板引擎;In response to a template engine setting operation for the query template, determine the template engine that needs to be used to render the query template based on a non-relational database;

响应对于所述查询模板的编辑操作,将预编译的非结构化查询语言指令、至少一个占位符以及用于描述所述非结构化查询语言指令的文本渲染方式的模板引擎指令生成为基于非关系型数据库的所述查询模板。In response to an editing operation on the query template, a precompiled unstructured query language instruction, at least one placeholder, and a template engine instruction for describing a text rendering method of the unstructured query language instruction are generated into a non-structured query template based on the non-structured query language instruction. The query template for a relational database.

本申请实施例中,为了适配类型为非关系型数据库的数据源,开发者还需要使用非关系型数据库支持的数据源查询指令语言、预先规定的占位符以及用于模板渲染的对应模板引擎指令,像查询关系型数据库时一样配置为用于渲染非结构化查询语言指令的非关系型查询模板,从而兼容对非关系型数据库的查询,适应用户更加多样化的查询需求。In the embodiment of this application, in order to adapt to data sources of non-relational database types, developers also need to use the data source query instruction language supported by non-relational databases, pre-specified placeholders, and corresponding templates for template rendering. The engine instructions are configured as non-relational query templates for rendering unstructured query language instructions just like when querying relational databases, so as to be compatible with queries to non-relational databases and adapt to users' more diverse query needs.

可选的,所述响应对于所述数据接口的对接操作,将所述数据接口发布至业务系统以提供数据查询之前,所述方法还包括:Optionally, before the response is to the docking operation of the data interface and the data interface is released to the business system to provide data query, the method further includes:

响应对于所述数据接口的后置计算配置操作,根据所述后置计算配置操作将后置处理器对接至所述数据接口,所述后置处理器用于根据用户的需要使用常规运算符对所述目标数据进行处理。In response to the post-computing configuration operation of the data interface, a post-processor is connected to the data interface according to the post-computing configuration operation, and the post-processor is used to use conventional operators according to user needs. The target data is processed.

本申请实施例中,通过为数据接口对接对应的后置处理器,以实现使用常规运算符对查询到的目标数据按照用户需求进行处理的效果,提高数据接口的灵活性和可定制性。In the embodiment of this application, the data interface is connected to the corresponding post-processor to achieve the effect of using conventional operators to process the queried target data according to user needs, thereby improving the flexibility and customizability of the data interface.

第二方面,本申请实施例提供了一种数据接口的配置装置,所述装置包括:In the second aspect, embodiments of the present application provide a data interface configuration device. The device includes:

数据源创建单元,用于响应对于数据接口的创建操作,为所述数据接口创建对应的数据源;A data source creation unit, used to respond to the creation operation of the data interface and create a corresponding data source for the data interface;

配置单元,用于响应对于所述数据接口的第一配置操作,根据所述第一配置操作确定所述数据接口对应的数据库驱动、数据库连接与查询模板,所述查询模板为使用占位符替换请求参数的预编译数据源查询指令;A configuration unit configured to respond to a first configuration operation for the data interface and determine the database driver, database connection and query template corresponding to the data interface according to the first configuration operation. The query template is replaced by a placeholder. Precompiled data source query instructions for request parameters;

所述配置单元,还用于响应对于所述数据接口的第二配置操作,根据所述第二配置操作创建所述数据接口对应的唯一接口信息,并确定所述唯一接口信息与所述数据库驱动、所述数据库连接以及所述查询模板之间的映射关系;The configuration unit is also configured to respond to a second configuration operation for the data interface, create unique interface information corresponding to the data interface according to the second configuration operation, and determine whether the unique interface information is consistent with the database driver. , the mapping relationship between the database connection and the query template;

对接单元,用于响应对于所述数据接口的对接操作,将所述数据接口发布至业务系统以提供数据查询。The docking unit is configured to respond to the docking operation of the data interface and publish the data interface to the business system to provide data query.

可选的,所述装置还包括:Optionally, the device also includes:

生成单元,用于响应对于所述数据接口的前置检查配置操作,根据所述前置检查配置操作生成必填参数规则,并将所述必填参数规则与所述数据接口进行绑定,所述必填参数规则用于检查用户发送给所述数据接口的请求参数中是否包含能够查询出目标数据的全部参数。A generating unit configured to respond to a pre-check configuration operation for the data interface, generate a required parameter rule according to the pre-check configuration operation, and bind the required parameter rule to the data interface, so The above required parameter rules are used to check whether the request parameters sent by the user to the data interface contain all parameters that can query the target data.

可选的,所述装置还包括:Optionally, the device also includes:

确定单元,用于响应对于所述查询模板的模板引擎设置操作,确定渲染基于关系型数据库的所述查询模板需要使用的模板引擎;A determining unit configured to respond to a template engine setting operation for the query template and determine the template engine that needs to be used to render the query template based on the relational database;

所述生成单元,还用于响应对于所述查询模板的编辑操作,将预编译的结构化查询语言指令、至少一个占位符以及用于描述所述结构化查询语言指令的文本渲染方式的模板引擎指令生成为基于关系型数据库的所述查询模板。The generating unit is also configured to respond to an editing operation on the query template, and generate a precompiled structured query language instruction, at least one placeholder, and a template used to describe the text rendering method of the structured query language instruction. The engine instructions are generated as the query template based on the relational database.

可选的,所述确定单元,还用于响应对于所述查询模板的模板引擎设置操作,确定渲染基于非关系型数据库的所述查询模板需要使用的模板引擎;Optionally, the determining unit is also configured to determine the template engine that needs to be used to render the query template based on a non-relational database in response to a template engine setting operation for the query template;

所述生成单元,还用于响应对于所述查询模板的编辑操作,将预编译的非结构化查询语言指令、至少一个占位符以及用于描述所述非结构化查询语言指令的文本渲染方式的模板引擎指令生成为基于非关系型数据库的所述查询模板The generating unit is also configured to respond to the editing operation of the query template and generate a precompiled unstructured query language instruction, at least one placeholder, and a text rendering method used to describe the unstructured query language instruction. The template engine instructions generate the query template based on the non-relational database

可选的,所述对接单元,还用于响应对于所述数据接口的后置计算配置操作,根据所述后置计算配置操作将后置处理器对接至所述数据接口,所述后置处理器用于根据用户的需要使用常规运算符对所述目标数据进行处理。Optionally, the docking unit is also configured to respond to a post-computing configuration operation for the data interface, and dock a post-processor to the data interface according to the post-computing configuration operation. The post-processing The processor is used to process the target data using conventional operators according to the user's needs.

应当理解的是,本申请实施例的第二方面与本申请实施例的第一方面的技术方案一致,各方面及对应的可行实施方式所取得的有益效果相似,不再赘述。It should be understood that the second aspect of the embodiments of the present application is consistent with the technical solution of the first aspect of the embodiments of the present application, and the beneficial effects achieved by each aspect and corresponding feasible implementations are similar, and will not be described again.

第三方面,本申请实施例提供了一种数据查询方法,所述方法包括:In a third aspect, embodiments of the present application provide a data query method, which method includes:

接收业务系统发送的查询请求,所述查询请求包括待查询的目标数据的唯一接口信息以及请求参数;Receive a query request sent by the business system, the query request including the unique interface information of the target data to be queried and the request parameters;

根据预先配置的唯一接口信息与查询模板的映射关系,查询出所述唯一接口信息对应的所述查询模板,所述查询模板为使用占位符替换请求参数的预编译数据源查询指令;According to the mapping relationship between the preconfigured unique interface information and the query template, query the query template corresponding to the unique interface information, where the query template is a precompiled data source query instruction that uses placeholders to replace request parameters;

将所述请求参数与所述查询模板导入模板引擎,渲染为数据源查询指令;Import the request parameters and the query template into a template engine and render them into data source query instructions;

根据所述唯一接口信息与所述数据源查询指令,从数据源查询出所述目标数据;Query the target data from the data source according to the unique interface information and the data source query instruction;

向所述业务系统发送所述目标数据。Send the target data to the business system.

本申请实施例中,通过在接受到业务系统发出的查询请求后,根据查询请求中的唯一接口信息获取对应的查询模板,并将查询请求中的请求参数与查询模板一同发送至模板引擎中,渲染出能够被数据库读取的指令;随后执行该指令以从数据库中获得目标数据并发送给业务系统,从而使用户便捷地从数据库平台中查询出目标数据,大幅降低使用数据库的操作门槛。In the embodiment of this application, after receiving the query request issued by the business system, the corresponding query template is obtained according to the unique interface information in the query request, and the request parameters in the query request and the query template are sent to the template engine. Render an instruction that can be read by the database; then execute the instruction to obtain the target data from the database and send it to the business system, allowing users to easily query the target data from the database platform and greatly reducing the operational threshold for using the database.

可选的,所述根据预先配置的唯一接口信息与查询模板的对应关系,查询出所述唯一接口信息对应的所述查询模板之前,所述方法还包括:Optionally, before querying the query template corresponding to the unique interface information according to the pre-configured correspondence between the unique interface information and the query template, the method further includes:

获取预先配置的必填参数规则,所述必填参数规则用于检查所述请求参数中是否包含从所述数据源中定位出所述目标数据必需的全部参数;Obtain preconfigured required parameter rules, which are used to check whether the request parameters contain all parameters necessary to locate the target data from the data source;

根据所述必填参数规则对所述请求参数进行检查;Check the request parameters according to the required parameter rules;

若所述请求参数检查不通过,输出错误信息,所述错误信息用于提示用户所述请求参数的填写不合法。If the request parameter check fails, an error message is output, and the error message is used to prompt the user that the filling in of the request parameter is illegal.

本申请实施例中,通过检查用户在查询目标数据时,所填写的请求参数中是否包含定位出目标数据所必需的全部参数,若不包含这些参数则返回错误信息,提醒用户参数填写不合法,从而让用户能够发现当前查询请求无法查询出目标数据并对其进行修改。In the embodiment of this application, by checking whether the request parameters filled in by the user when querying the target data include all the parameters necessary to locate the target data, if these parameters are not included, an error message will be returned to remind the user that the parameter filling is illegal. This allows users to discover that the current query request cannot query the target data and modify it.

可选的,所述查询请求中还包括用于处理所述目标数据的后置计算规则,所述后置计算规则包括一个或多个运算符,所述向所述业务系统发送所述目标数据包括:Optionally, the query request also includes post-calculation rules for processing the target data. The post-calculation rules include one or more operators. The target data is sent to the business system. include:

根据所述后置计算规则,使用后置处理器对所述目标数据进行计算,获得目标数据计算结果;According to the post-calculation rules, use a post-processor to calculate the target data to obtain the target data calculation results;

向所述业务系统发送所述目标数据计算结果。Send the target data calculation result to the business system.

本申请实施例中,在获取到数据源中的原始目标数据后,通过解析查询请求中包含的后置计算规则,对已经查询到的目标数据执行进一步的运算处理,从而直接输出用户需要的结果,增强数据查询的灵活性。In the embodiment of this application, after the original target data in the data source is obtained, further calculation processing is performed on the queried target data by parsing the post-calculation rules contained in the query request, thereby directly outputting the results required by the user. , enhance the flexibility of data query.

可选的,接收所述查询请求与发送所述目标数据的数据接口为唯一的对外接口。Optionally, the data interface for receiving the query request and sending the target data is the only external interface.

本申请实施例中,通过统一的对外接口接收和发送数据,从而解决了传统数据库平台需要针对每个业务系统都开放一个专用数据接口的问题,增强了数据接口管理的便捷性。In the embodiments of this application, data is received and sent through a unified external interface, thereby solving the problem that traditional database platforms need to open a dedicated data interface for each business system, and enhancing the convenience of data interface management.

【附图说明】[Picture description]

为了更清楚地说明本申请实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下文中描述中的附图仅仅是本说明书的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其它的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required to be used in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of this specification. Those of ordinary skill in the art can also obtain other drawings based on these drawings without exerting creative efforts.

图1为本申请实施例提供的一种目标数据的查询方法的流程示意图;Figure 1 is a schematic flow chart of a target data query method provided by an embodiment of the present application;

图2为本申请实施例中的一种必填参数规则的配置方法的流程示意图;Figure 2 is a schematic flowchart of a method for configuring required parameter rules in an embodiment of the present application;

图3为本申请实施例中的一种后置处理器的配置方法的流程示意图;Figure 3 is a schematic flowchart of a post-processor configuration method in an embodiment of the present application;

图4为本申请实施例中的一种基于关系数据库的查询模板配置方法的流程示意图;Figure 4 is a schematic flow chart of a query template configuration method based on a relational database in an embodiment of the present application;

图5为本申请实施例中的一种基于非关系数据库的查询模板配置方法的流程示意图;Figure 5 is a schematic flowchart of a query template configuration method based on a non-relational database in an embodiment of the present application;

图6为本申请实施例中的一种数据接口的配置装置的结构示意图;Figure 6 is a schematic structural diagram of a data interface configuration device in an embodiment of the present application;

图7为本申请实施例提供的一种数据查询方法的流程示意图;Figure 7 is a schematic flow chart of a data query method provided by an embodiment of the present application;

图8为本申请实施例提供的一种数据接口的运行逻辑图。Figure 8 is an operating logic diagram of a data interface provided by an embodiment of the present application.

【具体实施方式】【Detailed ways】

为了更好的理解本说明书的技术方案,下面结合附图对本申请实施例进行详细描述。In order to better understand the technical solutions of this specification, the embodiments of the present application will be described in detail below with reference to the accompanying drawings.

应当明确,所描述的实施例仅仅是本说明书一部分实施例,而不是全部的实施例。基于本说明书中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其它实施例,都属于本说明书保护的范围。It should be clear that the described embodiments are only some of the embodiments of this specification, but not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by those of ordinary skill in the art without making creative efforts fall within the scope of protection of this specification.

在本申请实施例中使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本说明书。在本申请实施例和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其他含义。The terminology used in the embodiments of the present application is for the purpose of describing specific embodiments only and is not intended to limit the specification. As used in the embodiments and the appended claims, the singular forms "a," "the" and "the" are intended to include the plural forms as well, unless the context clearly dictates otherwise.

目前,随着大数据技术的高速发展,很多企业、机构都将内部使用的业务系统与各种大数据平台提供的数据库平台接驳,以通过数据库平台整合、管理业务系统中产生的各种数据,降低企业与机构自身进行数据管理与运维的成本。At present, with the rapid development of big data technology, many enterprises and institutions are connecting their internal business systems with the database platforms provided by various big data platforms to integrate and manage various data generated in the business systems through the database platform. , Reduce the costs of data management and operation and maintenance for enterprises and institutions themselves.

本申请发明人研究发现,在利用这些数据库平台产品提供的接口查询相关业务数据时,往往需要使用者使用SQL代码自行编写查询指令,或者选用专业的数据库管理工具进行操作。而前者需要使用者具备一定的SQL编程基础,后者则往往因为管理工具的价格昂贵而使企业或机构难以负担;由于这些缺点,导致这类数据库平台的使用门槛与局限性高,无法适应多样化的目标数据查询需求。The inventor of the present application found through research that when using the interfaces provided by these database platform products to query relevant business data, users often need to use SQL codes to write their own query instructions, or use professional database management tools to operate. The former requires users to have a certain SQL programming foundation, while the latter is often difficult for enterprises or institutions to afford due to the high price of management tools. Due to these shortcomings, the use threshold and limitations of this type of database platform are high, and it is unable to adapt to a variety of applications. oriented target data query requirements.

鉴于此,本申请实施例提供了一种目标数据的查询方法,能够通过将用户的查询请求与对应的查询模板共同导入模板引擎,生成为能够查询出指定目标数据的数据源查询指令,让使用者只需对结构化查询语言具有基本了解便可对云端的业务数据进行查询,降低数据库平台的使用成本与操作门槛,满足各类目标数据的查询需求。In view of this, embodiments of the present application provide a target data query method, which can import the user's query request and the corresponding query template into the template engine to generate a data source query instruction that can query the specified target data, allowing users to Users only need to have a basic understanding of structured query language to query business data in the cloud, reducing the cost and operation threshold of the database platform and meeting the query needs of various target data.

下面结合附图对本申请实施例提供的技术方案进行介绍。请参见图1,本申请实施例提供了一种目标数据的查询方法,该方法的流程描述如下:The technical solutions provided by the embodiments of the present application will be introduced below with reference to the accompanying drawings. Please refer to Figure 1. This embodiment of the present application provides a method for querying target data. The process of the method is described as follows:

步骤101:响应对于数据接口的创建操作,为数据接口创建对应的数据源。Step 101: In response to the creation operation of the data interface, create a corresponding data source for the data interface.

具体的,在创建本申请实施例所需要的数据接口时,需要配置当前数据接口对应的数据源,即对相关业务数据进行存储以支持数据查询服务的程序基础。以关系型数据库为例,首先应创建当前数据源所使用的数据表(因为关系型数据库使用的存储结构限制,使其必须获取表名与列名以查询对应的数据表和数据列),这一步操作一般通过接入数据并选择需要的数据类型、设置日期等过滤条件、进行字段筛选、配置用户权限等步骤实现。然后,基于数据表建立配套的数据模型,配置开发者权限、数据源名称与表格名称,从而完成数据源的创建过程。Specifically, when creating the data interface required by the embodiment of this application, it is necessary to configure the data source corresponding to the current data interface, that is, the program basis for storing relevant business data to support data query services. Taking the relational database as an example, you should first create the data table used by the current data source (because of the storage structure limitations of the relational database, it is necessary to obtain the table name and column name to query the corresponding data table and data column). A one-step operation is generally implemented by accessing data and selecting the required data type, setting filter conditions such as date, filtering fields, and configuring user permissions. Then, establish a supporting data model based on the data table, configure developer permissions, data source name, and table name to complete the data source creation process.

步骤102:响应对于数据接口的第一配置操作,根据第一配置操作确定数据接口对应的数据库驱动、数据库连接与查询模板,查询模板为使用占位符替换请求参数的预编译数据源查询指令。Step 102: In response to the first configuration operation for the data interface, determine the database driver, database connection, and query template corresponding to the data interface according to the first configuration operation. The query template is a precompiled data source query instruction that uses placeholders to replace request parameters.

具体的,第一配置操作用于配置用户通过数据接口连接至目标数据源的方式,包括用于解析和执行数据查询指令的数据库驱动、用于传输目标数据的数据库连接,以及用于结合用户的查询请求进行文本渲染以得出数据查询指令的查询模板。Specifically, the first configuration operation is used to configure the way the user connects to the target data source through the data interface, including a database driver used to parse and execute data query instructions, a database connection used to transmit the target data, and a database connection used to combine the user's The query request performs text rendering to derive a query template for the data query instructions.

应理解的是,建立数据库连接最通用的方法,就是配置多个持续可用的连接对象,并在需要调用数据库连接时直接分配对应的连接对象,以减少创建连接和关闭连接的耗时。而这多个连接对象共同构成了数据库的“连接池”——一种负责分配、管理和释放数据库连接的动态机制,能够保留复数个已经存在的连接对象(如100个),并允许查询程序重复使用其中一个现有的数据库连接。It should be understood that the most common way to establish a database connection is to configure multiple continuously available connection objects, and directly allocate the corresponding connection object when a database connection needs to be called, so as to reduce the time-consuming creation and closing of the connection. These multiple connection objects together constitute the "connection pool" of the database - a dynamic mechanism responsible for allocating, managing and releasing database connections. It can retain a plurality of existing connection objects (such as 100) and allow query programs to Reuse one of the existing database connections.

步骤103:响应对于数据接口的第二配置操作,根据第二配置操作创建数据接口对应的唯一接口信息,并确定唯一接口信息与数据库驱动、数据库连接以及查询模板之间的映射关系。Step 103: Respond to the second configuration operation of the data interface, create unique interface information corresponding to the data interface according to the second configuration operation, and determine the mapping relationship between the unique interface information and the database driver, database connection, and query template.

具体的,第二配置操作主要用于对唯一接口信息中所规定的连接细节进行编辑。本申请实施例中,唯一接口信息主要负责在用户执行查询操作时,根据自身记载的连接信息定位出数据源以建立连接,进而使查询指令能够输入数据源并得到反馈的目标数据结果。Specifically, the second configuration operation is mainly used to edit the connection details specified in the unique interface information. In the embodiment of this application, the unique interface information is mainly responsible for locating the data source according to the connection information recorded in the user to establish a connection when the user performs a query operation, thereby enabling the query command to input the data source and obtain the feedback target data result.

唯一接口信息的具体配置项包括接口名称、接口版本号。接口名称主要负责记录数据接口类型、所接入的业务系统等信息,用于实现对数据接口的统一管理,而接口版本号则用于承载单次连接的具体连接细节。通过配置接口名称、接口版本号这两者与数据源类型、查询模板、用户名、密码、HOST信息(IP地址或域名)与POST字段(端口信息)等信息的映射关系,即可在用户通过数据接口查询时直接调阅相关信息,执行握手流程,建立业务系统与某个具体数据源之间的连接。The specific configuration items of unique interface information include interface name and interface version number. The interface name is mainly responsible for recording information such as the data interface type and the connected business system, and is used to achieve unified management of the data interface, while the interface version number is used to carry the specific connection details of a single connection. By configuring the mapping relationship between the interface name and interface version number and the data source type, query template, user name, password, HOST information (IP address or domain name) and POST field (port information), the user can pass When querying the data interface, the relevant information is directly retrieved, the handshake process is executed, and the connection between the business system and a specific data source is established.

步骤104:响应对于数据接口的对接操作,将数据接口发布至业务系统以提供数据查询。Step 104: In response to the docking operation of the data interface, publish the data interface to the business system to provide data query.

具体的,对接操作主要用于将某个数据接口与业务系统进行对接,即发布该开发完成的数据接口、将数据接口接入所对应的业务系统以向业务系统开放目标数据的查询。Specifically, the docking operation is mainly used to connect a certain data interface with the business system, that is, publish the developed data interface and connect the data interface to the corresponding business system to open the query of target data to the business system.

而在完成数据接口配置并发布之前,还需要根据实际的开发需求添加更多功能如必填参数校验,来对用户通过业务系统发送的查询请求是否合法进行验证。Before the data interface configuration is completed and released, more functions such as required parameter verification need to be added according to actual development needs to verify whether the query requests sent by users through the business system are legal.

图2是本申请实施例中的一种必填参数规则的配置方法。作为一种可能的实施方式,在步骤104之前,还可以进一步执行步骤105。Figure 2 is a configuration method of required parameter rules in an embodiment of the present application. As a possible implementation, before step 104, step 105 may be further performed.

步骤105:响应对于数据接口的前置检查配置操作,根据前置检查配置操作生成必填参数规则,并将必填参数规则与数据接口进行对接,必填参数规则用于检查用户发送给数据接口的请求参数中是否包含能够查询出目标数据的全部参数。Step 105: Respond to the pre-check configuration operation for the data interface, generate required parameter rules based on the pre-check configuration operation, and connect the required parameter rules with the data interface. The required parameter rules are used to check what the user sends to the data interface. Whether the request parameters contain all parameters that can query the target data.

本申请实施例中,数据接口开发者的前置检查配置操作主要用于:配置一个前置处理器以对用户发送的查询请求进行检查,判断其中包含的全部参数是否能够支持用户的本次查询操作,而用于检查查询请求的机制即为“必填参数规则”。In the embodiment of this application, the pre-check configuration operation of the data interface developer is mainly used to: configure a pre-processor to check the query request sent by the user, and determine whether all the parameters contained in it can support the user's query. operation, and the mechanism used to check the query request is the "required parameter rule".

具体的,该必填参数规则所检查的项目主要包括在数据源中定位出目标数据所必需的全部参数,如在关系型数据库中,请求参数一般必须包含查询目标数据所需的表名和列名,而在非关系型数据库中必填参数则根据不同数据源类型存在不同,一般包括数据库或集合名称、查询条件、查询投影、排序规则、分组规则等;而针对所需要查询的数据源类型不同,必填参数规则中还可能包含其它必填输入参数(如行名、唯一身份标识码、出厂日期等),用以支持对不同的数据源类型执行查询操作。Specifically, the items checked by this required parameter rule mainly include all parameters necessary to locate the target data in the data source. For example, in a relational database, the request parameters must generally include the table names and column names required to query the target data. , while in non-relational databases, required parameters vary according to different data source types, generally including database or collection name, query conditions, query projection, sorting rules, grouping rules, etc.; and the types of data sources that need to be queried are different. , the required parameter rules may also contain other required input parameters (such as row names, unique identification codes, factory dates, etc.) to support query operations on different data source types.

通过添加该前置处理器,即可在数据接口接到查询请求时根据必填参数规则进行校验,而非在数据源查询指令渲染失败、或使用已渲染指令查询失败时再返回错误提示。值得一提的是,为了满足快速配置的需求,前置检查配置操作的具体动作可以包括:自定义一个新的必填参数规则,或根据数据源的具体类型选择预设的必填参数规则并自定义修改。By adding this pre-processor, when the data interface receives a query request, it can be verified according to the required parameter rules, instead of returning an error message when the data source query command fails to render, or when the query using the rendered command fails. It is worth mentioning that in order to meet the needs of quick configuration, the specific actions of the pre-check configuration operation can include: customizing a new required parameter rule, or selecting a preset required parameter rule based on the specific type of data source and Custom modifications.

而在配置前置处理器之后,还应根据开发需求设置类似的后置处理器,用以满足更复杂的用户查询需求。After configuring the pre-processor, a similar post-processor should be set up according to development needs to meet more complex user query needs.

图3是本申请实施例中的一种后置处理器的配置方法。作为一种可能的实施方式,在步骤104之前,还可以进一步执行步骤106。Figure 3 is a configuration method of a post-processor in an embodiment of the present application. As a possible implementation, before step 104, step 106 may be further performed.

步骤106:响应对于数据接口的后置计算配置操作,根据后置计算配置操作将后置处理器对接至数据接口,后置处理器用于根据用户的需要使用常规运算符对目标数据进行处理。Step 106: In response to the post-computing configuration operation of the data interface, connect the post-processor to the data interface according to the post-computing configuration operation. The post-processor is used to process the target data using conventional operators according to the user's needs.

本申请实施例中,由于用户可能存在需要对查询到的目标数据进行额外处理的需求,因此开发者还需要根据这一需求配置数据接口对应的后置处理器。通过将后置处理器对接数据接口,可以在当前数据接口收到查询请求之后,通过解析查询请求中额外写入的后置计算规则,并按照规则中的运算符对查询得到的目标数据进行求和、求差、左移或右移、取特定值、统计字节数等特殊操作,从而让业务系统在接收查询结果时收到的即是目标数据的二次处理结果,也就是用户希望得到的结果。与前置处理器相似的,为了满足快速开发这一目的,后置配置操作的具体动作可以包括:自定义一个新的后置处理器,或根据业务系统的常规查询需求选择预设的后置处理器并自定义修改。In the embodiment of this application, since the user may need to perform additional processing on the queried target data, the developer also needs to configure the post-processor corresponding to the data interface according to this requirement. By connecting the post-processor to the data interface, after the current data interface receives the query request, the additional post-calculation rules written in the query request can be parsed, and the target data obtained from the query can be calculated according to the operators in the rules. Special operations such as sum, difference, left or right shift, specific value, and byte count statistics allow the business system to receive the secondary processing results of the target data when receiving query results, which is what the user hopes to get. the result of. Similar to the pre-processor, in order to meet the purpose of rapid development, the specific actions of the post-processor configuration operation can include: customizing a new post-processor, or selecting a preset post-processor based on the general query requirements of the business system. processor and custom modifications.

此外,在前置处理器、后置处理器配置完成的同时,还需要开发者对用于渲染数据源查询指令的查询模板进行配置,以确保用户查询目标数据的便捷性。In addition, when the pre-processor and post-processor are configured, developers also need to configure the query template used to render the data source query instructions to ensure the convenience of users querying the target data.

图4为本申请实施例中的一种基于关系数据库的查询模板配置方法。作为一种可能的实施方式,在步骤102之前,还可以进一步执行步骤107至108。Figure 4 is a query template configuration method based on a relational database in an embodiment of the present application. As a possible implementation, before step 102, steps 107 to 108 may be further performed.

步骤107:响应对于查询模板的模板引擎设置操作,确定渲染基于关系型数据库的查询模板需要使用的模板引擎。Step 107: In response to the template engine setting operation for the query template, determine the template engine that needs to be used to render the query template based on the relational database.

步骤108:响应对于查询模板的编辑操作,将预编译的结构化查询语言指令、至少一个占位符以及用于描述结构化查询语言指令的文本渲染方式的模板引擎指令生成为基于关系型数据库的查询模板。Step 108: In response to the editing operation of the query template, generate the precompiled structured query language instruction, at least one placeholder, and a template engine instruction used to describe the text rendering method of the structured query language instruction into a relational database-based Query template.

本申请实施例中,为了能使用户无需输入完整的查询指令即可查询到目标数据,需要开发者提前配置本次数据源查询操作可用的查询模板。具体而言,当查询的数据库为关系型数据库时,生成查询模板首先需要开发者根据数据源的类型选择对应的模板引擎、设计数据源查询指令的抽象语法树,并使用对应的结构化查询语言将该抽象语法树编译为正式的数据源查询指令,其中具体的变量内容需要使用占位符进行代替。In the embodiment of this application, in order to enable the user to query the target data without inputting a complete query command, the developer needs to configure the query template available for this data source query operation in advance. Specifically, when the query database is a relational database, generating a query template first requires the developer to select the corresponding template engine according to the type of data source, design the abstract syntax tree of the data source query instructions, and use the corresponding structured query language Compile the abstract syntax tree into a formal data source query instruction, in which the specific variable content needs to be replaced by placeholders.

例如,当用户希望从某个用于记录客户信息的关系型数据库的表格中查询姓名为“XiaoMing”的客户数据时,传统方法需要用户输入一段内容为“SELECT*FROM CustomerWHERE Name='XiaoMing';”的完整查询指令,其含义为查找Customer(客户)表中所有姓名为"XiaoMing"的客户信息,并返回相应信息。而在本申请实施例中,开发者会事先在模板中编写内容为“SELECT*FROM Customer WHERE Name='{{Name}}';”的预编译语句,其中占位符“{{Name}}”即用来指代了具体的客户姓名信息,使用户只需输入必填参数“XiaoMing”,便可在模板引擎的文本渲染后得到所需要的SQL指令。For example, when a user wants to query customer data named "XiaoMing" from a table in a relational database used to record customer information, the traditional method requires the user to enter a piece of content as "SELECT*FROM CustomerWHERE Name='XiaoMing'; "The complete query command means to find all the customer information named "XiaoMing" in the Customer table and return the corresponding information. In the embodiment of this application, the developer will write a precompiled statement with the content "SELECT*FROM Customer WHERE Name='{{Name}}';" in the template in advance, in which the placeholder "{{Name}} " is used to refer to specific customer name information, so that users only need to enter the required parameter "XiaoMing" to get the required SQL instructions after text rendering by the template engine.

另一方面,为了满足更多样化的查询需要,本申请实施例中的查询模板还可包括能够被模板引擎读取并执行的一般编程语言(所使用的编程语言可包括C语言、python、汇编语言、java等类型,并且根据不同的模板引擎所支持的语言库存在区别,关于模板引擎的介绍将在下文中详细给出),用于告知模板引擎需要如何对查询模板与请求参数相结合以进行渲染,即上文中的模板引擎指令。为了和模板中的查询指令进行区分,避免在导入模板引擎后发生读取错误,模板引擎指令可以通过添加“{%指令内容%}”形式的符号限定进行区分。On the other hand, in order to meet more diverse query needs, the query template in the embodiment of the present application may also include a general programming language that can be read and executed by the template engine (the programming language used may include C language, python, Assembly language, Java and other types, and there are differences according to the language libraries supported by different template engines. An introduction to the template engine will be given in detail below), which is used to inform the template engine how to combine the query template with the request parameters. Rendering is the template engine command above. In order to distinguish it from the query instructions in the template and avoid reading errors after importing the template engine, the template engine instructions can be distinguished by adding symbol qualifications in the form of "{% instruction content%}".

例如,为了对一条查询请求中若干个用户想要查询的目标数据进行拆分,可以使用“{%for查询对象in查询表格%}”等基本的编程语言来执行循环,每次循环都按照顺序从查询请求的多条请求参数中抽取一条并与查询模板生成一条查询指令,以实现仅包含预编译查询语句的模板无法实现的“一条查询请求对应生成多条查询指令”的效果。在其中一种实施例中,具体生成的查询模板格式如下:For example, in order to split the target data that several users want to query in a query request, you can use basic programming languages such as "{%for query object in query table%}" to execute loops. Each loop will follow the order. Extract one of the multiple request parameters of the query request and generate a query instruction with the query template to achieve the effect of "one query request corresponding to multiple query instructions" that cannot be achieved by a template that only contains precompiled query statements. In one embodiment, the specifically generated query template format is as follows:

{%for Name in NameList%}{%for Name in NameList%}

#执行循环,告知模板引擎如何从查询请求中的姓名列表(多个请求参数)中提取出用于查询单个客户姓名的参数(单个数据的地址)。#Execute the loop to tell the template engine how to extract the parameters for querying a single customer name (the address of a single data) from the name list (multiple request parameters) in the query request.

{"Name":"{{Name}}"};{"Name":"{{Name}}"};

#规定占位符含义。#Specify the meaning of placeholders.

SELECT*FROM Customer WHERE Name='{{Name}}'SELECT*FROM Customer WHERE Name='{{Name}}'

#预编译的SQL语句。#Precompiled SQL statements.

{%if loop.last==false%}&{%endif%}{%if loop.last==false%}&{%endif%}

#当全部请求参数被提取时,终止判断。#When all request parameters are extracted, terminate the judgment.

{%endfor%}{%endfor%}

#跳出循环。#Jump out of the loop.

此外,还可以通过更加复杂的指令编程,在模板中实现更多样的查询指令文本渲染效果。而当本次查询所需的查询模板已被事先编辑好、并在用户查询时调取完成后,就可以通过将查询模板与请求参数加工为查询指令来进行数据库查询了。In addition, more complex query instruction text rendering effects can be achieved in templates through more complex instruction programming. When the query template required for this query has been edited in advance and retrieved when the user queries, the database query can be performed by processing the query template and request parameters into query instructions.

而在编写查询模板之前,开发者还需要对该数据接口配置相应的模板引擎。如上所述,模板引擎在本申请实施例中主要用于对查询模板进行文本渲染,以输出能够在数据库中查询相关数据的具体查询指令。而在一般的应用场景中,模板引擎的本质是一种为了使用户界面与业务数据分离而产生的语言处理工具,它可以将输入的参数与带有一些声明、语法或格式限制的文本模板进行拼接(在拼接过程中,文本模板中事先声明的占位符被对应类型的参数所替换),输出一段具有特定格式的文本。目前市面上常用的模板引擎包括Thymeleaf、Jap等,而本申请实施例选取其中一种性能较为出色的引擎:“JinJa2”来进行文本渲染;该模板引擎常用于渲染python程序中的特定代码段,但在渲染由其它编程语言编写的代码指令时同样工作稳定,并且支持使用C语言、Java等编程语言编写的模板引擎指令。因此,JinJa2可以应用于查询模板生成指令的流程中。但由于对查询模板执行文本渲染时,采用其它模板引擎同样能够达到类似效果,故在此不对模板引擎的类型做任何限制。Before writing a query template, developers also need to configure the corresponding template engine for the data interface. As mentioned above, in the embodiment of the present application, the template engine is mainly used for text rendering of the query template to output specific query instructions that can query relevant data in the database. In general application scenarios, the essence of a template engine is a language processing tool produced to separate the user interface from business data. It can compare input parameters with text templates with some declaration, syntax or format restrictions. Splicing (during the splicing process, the placeholders declared in advance in the text template are replaced by parameters of the corresponding type), outputting a piece of text with a specific format. Currently, commonly used template engines on the market include Thymeleaf, Jap, etc., and the embodiment of this application selects one of the engines with relatively excellent performance: "JinJa2" for text rendering; this template engine is often used to render specific code segments in python programs. However, it also works stably when rendering code instructions written in other programming languages, and supports template engine instructions written in C language, Java and other programming languages. Therefore, JinJa2 can be applied in the process of query template generation instructions. However, since other template engines can also be used to achieve similar effects when performing text rendering on query templates, there is no restriction on the type of template engine here.

而当确定了数据接口对应的模板引擎后,即可按照上述方法针对性地配置该模板引擎所支持的基于关系型数据库的查询模板。此外,当查询模板所对应的数据源为非关系型数据库时,结构化查询语言指令显然无法对其进行查询,因此,需要开发者使用非结构化查询语言格式重新编程对应的查询模板。Once the template engine corresponding to the data interface is determined, the query template based on the relational database supported by the template engine can be configured according to the above method. In addition, when the data source corresponding to the query template is a non-relational database, the structured query language instructions obviously cannot query it. Therefore, developers need to reprogram the corresponding query template using the unstructured query language format.

图5是一种基于非关系数据库的查询模板配置方法。作为一种可能的实施方式,在步骤102之前,还可以进一步执行步骤109至110。Figure 5 is a query template configuration method based on a non-relational database. As a possible implementation, before step 102, steps 109 to 110 may be further performed.

步骤109:响应对于查询模板的模板引擎设置操作,确定渲染基于非关系型数据库的查询模板需要使用的模板引擎。Step 109: In response to the template engine setting operation for the query template, determine the template engine that needs to be used to render the query template based on the non-relational database.

步骤110:响应对于查询模板的编辑操作,将预编译的非结构化查询语言指令、至少一个占位符以及用于描述非结构化查询语言指令的文本渲染方式的模板引擎指令生成为基于非关系型数据库的查询模板。Step 110: In response to the editing operation on the query template, generate the precompiled unstructured query language instruction, at least one placeholder, and a template engine instruction for describing a text rendering method of the unstructured query language instruction into a non-relational based Query template for type database.

本申请实施例中,基于非关系型数据库的查询模板同样需要通过查询模板的编辑操作来生成,但其数据库类型相比关系型数据库更庞杂、不同数据库之间的差距类型较大(如MongoDB、Cassandra、Redis、Neo4j、Amazon DynamoDB、Couchbase、HBase、Riak等非关系型数据库,彼此之间数据存储结构和查询方式都有很大差别),因此需要逐个对查询模板进行配置。具体来说,由于数据接口适配的数据源类型较多,不同非关系型数据库所支持的数据库驱动类型也存在区别,进而导致当查询目标数据的数据源类型不同时,对应查询指令的格式或代码细节也需要相应调整。以下是几种非关系型数据库查询指令的差别案例:In the embodiment of the present application, the query template based on the non-relational database also needs to be generated through the editing operation of the query template, but its database type is more complex than the relational database, and the gap between different databases is larger (such as MongoDB, Non-relational databases such as Cassandra, Redis, Neo4j, Amazon DynamoDB, Couchbase, HBase, and Riak have very different data storage structures and query methods, so the query templates need to be configured one by one. Specifically, because the data interface adapts to many types of data sources, the types of database drivers supported by different non-relational databases are also different, which leads to the format or format of the corresponding query instructions when the data source types for querying the target data are different. Code details also need to be adjusted accordingly. The following are different examples of several non-relational database query instructions:

(1)MongoDB的查询指令与Couchbase的查询指令(1) MongoDB query instructions and Couchbase query instructions

MongoDB的查询语言是基于JavaScript的,使用的指令是find()、count()、distinct()等,查询语法比较简单。而Couchbase使用的查询语言是基于N1QL的,也是一种SQL类语言,可以实现SQL的各种操作,比如SELECT、JOIN、GROUP BY等,具有丰富的查询功能和灵活性。MongoDB's query language is based on JavaScript, and the commands used are find(), count(), distinct(), etc. The query syntax is relatively simple. The query language used by Couchbase is based on N1QL, which is also a SQL-like language that can implement various SQL operations, such as SELECT, JOIN, GROUP BY, etc., and has rich query functions and flexibility.

(2)Cassandra的查询指令与ScyllaDB的查询指令(2) Cassandra’s query instructions and ScyllaDB’s query instructions

Cassandra使用CQL语言进行查询,CQL与SQL语法有些类似,但是有一些不同之处,比如不支持JOIN操作。ScyllaDB同样使用CQL语言进行查询,但是它对CQL进行了一些改进,支持更多的语法,比如JOIN操作,而且引入了类似索引的数据结构来提高查询效率。Cassandra uses the CQL language for querying. CQL is somewhat similar to SQL syntax, but has some differences. For example, it does not support JOIN operations. ScyllaDB also uses the CQL language for querying, but it makes some improvements to CQL, supports more syntax, such as JOIN operations, and introduces index-like data structures to improve query efficiency.

(3)Amazon DynamoDB的查询指令与Apache HBase的查询指令(3) Amazon DynamoDB query instructions and Apache HBase query instructions

Amazon DynamoDB的查询指令使用的是AWS SDK中的API,而不是单独的查询指令。开发者可以根据需要来选择相应的API进行查询操作。Apache HBase的查询指令使用HBaseAPI,也可以使用Hadoop的API来进行查询操作,可以实现SQL类语句的各种操作。Amazon DynamoDB's query instructions use the API in the AWS SDK instead of separate query instructions. Developers can select the corresponding API for query operations as needed. Apache HBase's query instructions use HBaseAPI, and Hadoop's API can also be used to perform query operations, which can implement various operations of SQL-like statements.

因此,开发者根据数据接口能够支持的全部非关系型数据库类型,每个类型的数据库都编写一套专用的查询模板,能够适应用户查询不同非关系型数据库的需求。Therefore, developers write a set of dedicated query templates for each type of database based on all non-relational database types that the data interface can support, which can adapt to users' needs for querying different non-relational databases.

请参见图6,基于同一发明构思,本申请实施例还提供了一种数据接口的配置装置,该装置包括:数据源创建单元201、配置单元202、对接单元203。Referring to Figure 6, based on the same inventive concept, an embodiment of the present application also provides a data interface configuration device. The device includes: a data source creation unit 201, a configuration unit 202, and a docking unit 203.

其中:in:

数据源创建单元201,用于响应对于数据接口的创建操作,为数据接口创建对应的数据源;The data source creation unit 201 is used to respond to the creation operation of the data interface and create a corresponding data source for the data interface;

配置单元202,用于响应对于数据接口的第一配置操作,根据第一配置操作确定数据接口对应的数据库驱动、数据库连接与查询模板,查询模板为使用占位符替换请求参数的预编译数据源查询指令;The configuration unit 202 is configured to respond to the first configuration operation of the data interface and determine the database driver, database connection and query template corresponding to the data interface according to the first configuration operation. The query template is a precompiled data source that uses placeholders to replace request parameters. query instructions;

配置单元202,还用于响应对于数据接口的第二配置操作,根据第二配置操作创建数据接口对应的唯一接口信息,并确定唯一接口信息与数据库驱动、数据库连接以及查询模板之间的映射关系;The configuration unit 202 is also configured to respond to the second configuration operation for the data interface, create unique interface information corresponding to the data interface according to the second configuration operation, and determine the mapping relationship between the unique interface information and the database driver, database connection, and query template. ;

对接单元203,用于响应对于数据接口的对接操作,将数据接口发布至业务系统以提供数据查询。The docking unit 203 is used to respond to the docking operation of the data interface and publish the data interface to the business system to provide data query.

可选的,该装置还包括:Optionally, the device also includes:

生成单元,用于响应对于数据接口的前置检查配置操作,根据前置检查配置操作生成必填参数规则,并将必填参数规则与数据接口进行绑定,必填参数规则用于检查用户发送给数据接口的请求参数中是否包含能够查询出目标数据的全部参数。The generation unit is used to respond to the pre-check configuration operation of the data interface, generate required parameter rules based on the pre-check configuration operation, and bind the required parameter rules to the data interface. The required parameter rules are used to check the user sent Whether the request parameters to the data interface contain all parameters that can query the target data.

可选的,该装置还包括:Optionally, the device also includes:

确定单元,用于响应对于查询模板的模板引擎设置操作,确定渲染基于关系型数据库的查询模板需要使用的模板引擎;The determination unit is used to respond to the template engine setting operation for the query template and determine the template engine that needs to be used to render the query template based on the relational database;

生成单元,还用于响应对于查询模板的编辑操作,将预编译的结构化查询语言指令、至少一个占位符以及用于描述结构化查询语言指令的文本渲染方式的模板引擎指令生成为基于关系型数据库的查询模板。The generation unit is also configured to respond to an editing operation on the query template and generate the precompiled structured query language instruction, at least one placeholder, and a template engine instruction used to describe a text rendering method of the structured query language instruction into a relation-based Query template for type database.

可选的,确定单元还用于:响应对于查询模板的模板引擎设置操作,确定渲染基于非关系型数据库的查询模板需要使用的模板引擎;Optionally, the determining unit is also used to: respond to the template engine setting operation for the query template, and determine the template engine that needs to be used to render the query template based on the non-relational database;

生成单元,还用于响应对于查询模板的编辑操作,将预编译的非结构化查询语言指令、至少一个占位符以及用于描述非结构化查询语言指令的文本渲染方式的模板引擎指令生成为基于非关系型数据库的查询模板The generation unit is also configured to respond to the editing operation of the query template and generate the precompiled unstructured query language instruction, at least one placeholder, and a template engine instruction used to describe the text rendering method of the unstructured query language instruction into Query template based on non-relational database

可选的,对接单元203,还用于响应对于数据接口的后置计算配置操作,根据后置计算配置操作将后置处理器对接至数据接口,后置处理器用于根据用户的需要使用常规运算符对目标数据进行处理。Optionally, the docking unit 203 is also used to respond to the post-computing configuration operation of the data interface, and dock the post-processor to the data interface according to the post-computing configuration operation. The post-processor is used to use conventional operations according to the needs of the user. character to process the target data.

请参见图7,基于同一发明构思,本申请实施例还提供了一种数据查询方法,该方法的流程如下:Please refer to Figure 7. Based on the same inventive concept, the embodiment of the present application also provides a data query method. The process of the method is as follows:

步骤301:接收业务系统发送的查询请求,查询请求包括待查询的目标数据的唯一接口信息以及请求参数。Step 301: Receive a query request sent by the business system. The query request includes unique interface information and request parameters of the target data to be queried.

步骤302:根据预先配置的唯一接口信息与查询模板的映射关系,查询出唯一接口信息对应的查询模板,查询模板为使用占位符替换请求参数的预编译数据源查询指令。Step 302: Query the query template corresponding to the unique interface information according to the preconfigured mapping relationship between the unique interface information and the query template. The query template is a precompiled data source query instruction that uses placeholders to replace request parameters.

步骤303:将请求参数与查询模板导入模板引擎,渲染为数据源查询指令。Step 303: Import the request parameters and query template into the template engine and render them into data source query instructions.

步骤304:根据唯一接口信息与数据源查询指令,从数据源查询出目标数据。Step 304: Query the target data from the data source according to the unique interface information and data source query instructions.

步骤305:向业务系统发送目标数据。Step 305: Send target data to the business system.

本申请实施例中,可以通过开发者预先配置的唯一接口信息与查询模板之间的对应关系,快速查出对应的查询模板,并与用户输入的请求参数一起导入预先指定的模板引擎,生成数据源查询指令并与唯一接口信息共同查询出目标数据。In the embodiment of this application, the corresponding query template can be quickly found through the correspondence between the unique interface information and the query template pre-configured by the developer, and imported into the pre-specified template engine together with the request parameters input by the user to generate data The source query command is used together with the unique interface information to query the target data.

作为一种可能的实施方式,在步骤302之前,还可以进一步执行步骤306至As a possible implementation, before step 302, steps 306 to

步骤306:获取预先配置的必填参数规则,必填参数规则用于检查请求参数中是否包含从数据源中定位出目标数据必需的全部参数。Step 306: Obtain preconfigured required parameter rules. The required parameter rules are used to check whether the request parameters contain all parameters necessary to locate the target data from the data source.

步骤307:根据必填参数规则对请求参数进行检查。Step 307: Check the request parameters according to the required parameter rules.

步骤308:若请求参数检查不通过,输出错误信息,错误信息用于提示用户请求参数的填写不合法。Step 308: If the request parameter check fails, an error message is output. The error message is used to prompt the user that the filling in of the request parameters is illegal.

本申请实施例中,在根据用户输入的查询请求查询出目标数据之前,还需要使用预先使用的必填参数规则对查询请求进行校验,如果校验不通过,则提示用户参数填写的类型不正确,需要重新筛查并纠正。In the embodiment of this application, before querying the target data according to the query request input by the user, it is also necessary to use the pre-used required parameter rules to verify the query request. If the verification fails, the user is prompted to fill in the parameters in an incorrect type. Correct, needs to be rescreened and corrected.

作为一种可能的实施方式,步骤305可以通过子步骤3051至3052来具体实现。As a possible implementation, step 305 can be specifically implemented through sub-steps 3051 to 3052.

步骤3051:根据后置计算规则,使用后置处理器对目标数据进行计算,获得目标数据计算结果。Step 3051: According to the post-calculation rules, use the post-processor to calculate the target data and obtain the target data calculation result.

步骤3052:向业务系统发送目标数据计算结果。Step 3052: Send the target data calculation result to the business system.

本申请实施例中,当业务系统发送目标数据时,还可以根据用户查询请求中额外填写的后置计算规则调用相应运算符,对原始的目标数据二次处理后得到用户所需要的处理结果,并将该结果传回给用户。In the embodiment of this application, when the business system sends the target data, it can also call the corresponding operator according to the post-calculation rules additionally filled in the user's query request, and then process the original target data twice to obtain the processing results required by the user. and pass the result back to the user.

此外,传统的数据库查询技术中,数据库平台针对每个对接的业务系统都会分配一个专属的数据接口,而这一方法的缺点就是在对数据接口进行整理、删除等操作时,需要付出大量额外的管理成本。而本申请实施例中,接收查询请求与发送目标数据的接口为唯一的对外接口,其查询不同数据的区分方式与唯一接口信息有关。In addition, in traditional database query technology, the database platform allocates an exclusive data interface for each connected business system. The disadvantage of this method is that it requires a lot of extra effort when sorting and deleting the data interface. Administrative costs. In the embodiment of this application, the interface for receiving the query request and sending the target data is the only external interface, and the way of distinguishing the query for different data is related to the unique interface information.

具体来讲,接口名称决定了向业务系统提供的数据接口,而其接口版本号则承载了业务系统在接入数据接口时的连接细节,这使得在需要更新数据时,只用配置一项新的接口版本号即可快速完成更新,而不需要额外搭建新的数据接口和重新接入业务系统。对于在业务系统与各数据库间建立连接的详细步骤,则在根据唯一接口信息提取预配置的内容后,交给后续的网关与数据库连接池执行。通过这种方法,能够在减少数据接口管理成本的同时有效降低数据库平台的开发难度。Specifically, the interface name determines the data interface provided to the business system, and its interface version number carries the connection details of the business system when accessing the data interface. This allows only one new configuration to be configured when data needs to be updated. The interface version number can be quickly updated without the need to build a new data interface and reconnect to the business system. For the detailed steps of establishing a connection between the business system and each database, after extracting the preconfigured content based on the unique interface information, it is handed over to the subsequent gateway and database connection pool for execution. Through this method, it can effectively reduce the development difficulty of the database platform while reducing the cost of data interface management.

值得注意的是,通过本申请实施例中所提供的数据接口配置方法进行快速开发得到的数据接口,其在用户通过上述数据查询方法进行查询时的运行逻辑和具体实现效果如图8所示。It is worth noting that the data interface quickly developed through the data interface configuration method provided in the embodiment of this application has its operating logic and specific implementation effect when the user queries through the above data query method, as shown in Figure 8.

以上所述仅为本说明书的较佳实施例而已,并不用以限制本说明书,凡在本说明书的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本说明书保护的范围之内。The above are only preferred embodiments of this specification and are not intended to limit this specification. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of this specification shall be included in this specification. within the scope of protection.

Claims (10)

1. A method for configuring a data interface, the method comprising:
responding to the creation operation of a data interface, and creating a corresponding data source for the data interface;
responding to a first configuration operation of the data interface, and determining a database driver, a database connection and a query template corresponding to the data interface according to the first configuration operation, wherein the query template is a pre-compiled data source query instruction using a placeholder to replace a request parameter;
responding to a second configuration operation of the data interface, creating unique interface information corresponding to the data interface according to the second configuration operation, and determining a mapping relation among the unique interface information, the database driver, the database connection and the query template;
And responding to the docking operation of the data interface, and issuing the data interface to a service system to provide data inquiry.
2. The method of claim 1, wherein in response to a docking operation for the data interface, prior to publishing the data interface to a business system to provide a data query, the method further comprises:
and responding to the pre-checking configuration operation of the data interface, generating a rule of necessary parameters according to the pre-checking configuration operation, and binding the rule of necessary parameters with the data interface, wherein the rule of necessary parameters is used for checking whether all parameters capable of inquiring target data are contained in request parameters sent to the data interface by a user.
3. The method of claim 1, wherein the data source is a relational database, and wherein the responding is responsive to a first configuration operation of the data interface, and wherein prior to determining the database driver, database connection, and query template corresponding to the data interface according to the first configuration operation, the method further comprises:
determining a template engine to be used for rendering the query template based on a relational database in response to a template engine setting operation for the query template;
In response to an editing operation on the query template, a precompiled structured query language instruction, at least one placeholder, and template engine instructions for describing a text rendering manner of the structured query language instruction are generated as the query template based on a relational database.
4. The method of claim 1, wherein the data source is a non-relational database, the responding is responsive to a first configuration operation of the data interface, and the method further comprises, prior to determining a database driver, a database connection, and a query template corresponding to the data interface according to the first configuration operation:
determining a template engine to be used for rendering the query template based on a non-relational database in response to a template engine setting operation for the query template;
in response to an editing operation on the query template, a precompiled unstructured query language instruction, at least one placeholder, and a template engine instruction for describing a text rendering manner of the unstructured query language instruction are generated as the query template based on a non-relational database.
5. The method of claim 2, wherein the responding to the binding operation for the data interface, prior to binding the data interface with the business system, further comprises:
And responding to the post-calculation configuration operation of the data interface, binding a post-processor to the data interface according to the post-calculation configuration operation, wherein the post-processor is used for processing the target data according to the requirement of a user by using a conventional operator.
6. A device for configuring a data interface, the device comprising:
a data source creation unit, configured to create a corresponding data source for a data interface in response to a creation operation for the data interface;
the configuration unit is used for responding to a first configuration operation of the data interface, determining a database driver, a database connection and a query template corresponding to the data interface according to the first configuration operation, wherein the query template is a pre-compiled data source query instruction using a placeholder to replace a request parameter;
the configuration unit is further used for responding to a second configuration operation of the data interface, creating unique interface information corresponding to the data interface according to the second configuration operation, and determining a mapping relation among the unique interface information, the database driver, the database connection and the query template;
And the binding unit is used for responding to the binding operation of the data interface and binding the data interface with the service system.
7. A method of querying data, the method comprising:
receiving a query request sent by a service system, wherein the query request comprises unique interface information of target data to be queried and request parameters;
inquiring the inquiry template corresponding to the unique interface information according to the mapping relation between the pre-configured unique interface information and the inquiry template, wherein the inquiry template is a pre-compiled data source inquiry instruction using a placeholder to replace a request parameter;
importing the request parameters and the query templates into a template engine, and rendering the request parameters and the query templates into data source query instructions;
inquiring the target data from a data source according to the unique interface information and the data source inquiry instruction;
and sending the target data to the service system.
8. The method according to claim 7, wherein before the query template corresponding to the unique interface information is queried according to the corresponding relationship between the pre-configured unique interface information and the query template, the method further comprises:
Acquiring a pre-configured rule of necessary parameters, wherein the rule of necessary parameters is used for checking whether all parameters necessary for locating the target data from the data source are contained in the request parameters;
checking the request parameters according to the rule of the necessary parameters;
if the request parameters are not checked, outputting error information, wherein the error information is used for prompting a user that filling of the request parameters is illegal.
9. The method of claim 7, wherein the query request further includes post-computation rules for processing the target data, the post-computation rules including one or more operators, the sending the target data to the business system comprising:
calculating the target data by using a post processor according to the post calculation rule to obtain a target data calculation result;
and sending the target data calculation result to the service system.
10. The method of claim 7, wherein the data interface receiving the query request and transmitting the target data is a unique external interface.
CN202310453518.XA 2023-04-25 2023-04-25 Configuration method, device and data query method of data interface Pending CN116755685A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310453518.XA CN116755685A (en) 2023-04-25 2023-04-25 Configuration method, device and data query method of data interface

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310453518.XA CN116755685A (en) 2023-04-25 2023-04-25 Configuration method, device and data query method of data interface

Publications (1)

Publication Number Publication Date
CN116755685A true CN116755685A (en) 2023-09-15

Family

ID=87946697

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310453518.XA Pending CN116755685A (en) 2023-04-25 2023-04-25 Configuration method, device and data query method of data interface

Country Status (1)

Country Link
CN (1) CN116755685A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100262902A1 (en) * 2009-04-08 2010-10-14 Microsoft Corporation Schema Based User Interface Mechanisms
CN110083650A (en) * 2019-04-25 2019-08-02 中电科嘉兴新型智慧城市科技发展有限公司 A kind of data-query interfaces automatic generation method and system based on metadata self-discovery
CN112395138A (en) * 2020-11-20 2021-02-23 北京华胜天成科技股份有限公司 Method and device for checking parameters
CN115982257A (en) * 2022-12-13 2023-04-18 平安银行股份有限公司 Interface creation method and related device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100262902A1 (en) * 2009-04-08 2010-10-14 Microsoft Corporation Schema Based User Interface Mechanisms
CN110083650A (en) * 2019-04-25 2019-08-02 中电科嘉兴新型智慧城市科技发展有限公司 A kind of data-query interfaces automatic generation method and system based on metadata self-discovery
CN112395138A (en) * 2020-11-20 2021-02-23 北京华胜天成科技股份有限公司 Method and device for checking parameters
CN115982257A (en) * 2022-12-13 2023-04-18 平安银行股份有限公司 Interface creation method and related device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
波哈维·荻西特: "《深入理解Elasticsearch(原书第3版)》", 31 January 2020, 机械工业出版社, pages: 43 - 45 *

Similar Documents

Publication Publication Date Title
CN115017182B (en) Visual data analysis method and device
CN111190924A (en) Cross-domain data query method and device
WO2016123920A1 (en) Method and system for achieving integration interface supporting operations of multiple types of databases
CN102541521B (en) Automatic operating instruction generating device based on structured query language and method
CN102279750B (en) Iterative code generation method based on domain knowledge sharing
CN103020158A (en) Report form creation method, device and system
CN104133772A (en) Automatic test data generation method
CN106897322A (en) The access method and device of a kind of database and file system
CN110187916B (en) Method for generating Word document based on data configuration
CN108762743A (en) Data table operation code generation method and device
CN109241384B (en) Scientific research information visualization method and device
CN111158687B (en) JAVA plug-in interface generation method, device, computer equipment and storage medium
CN114925142B (en) A multi-type database compatibility method, device, equipment and medium for an ORM framework
CN110990011A (en) Data request method of automation interface
CN114356964A (en) Data lineage construction method, device, storage medium and electronic device
US8171045B2 (en) Record based code structure
CN113761040A (en) Database and application program bidirectional mapping method, device, medium and program product
KR20210012400A (en) Method of building backend with automatic programming code generation
CN113918149A (en) Interface development method, apparatus, computer equipment and storage medium
WO2024016850A1 (en) Method and system for processing data conflict, and electronic device and computer-readable storage medium
CN116594676A (en) Application packaging method, device, equipment and storage medium
CN116069577A (en) A kind of interface test method, equipment and medium of RPC service
CN118152522B (en) Data query method, device, electronic device, storage medium and product
CN115145558A (en) Visual code-free or light code cloud development method and system
TWI629602B (en) Method for automatically generating website interactive program

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
TA01 Transfer of patent application right

Effective date of registration: 20240115

Address after: No. 13 Xingxiang Road, Zengjia Town, High tech Zone, Shapingba District, Chongqing, 400039

Applicant after: Chongqing Selis Phoenix Intelligent Innovation Technology Co.,Ltd.

Address before: Room 2901, Floor 29, Unit 1, Building 1, No. 151, Tianfu Second Street, Chengdu Hi tech Zone, Chengdu Free Trade Pilot Zone, 610,000, Sichuan

Applicant before: Chengdu Thalys Technology Co.,Ltd.

TA01 Transfer of patent application right
RJ01 Rejection of invention patent application after publication

Application publication date: 20230915

RJ01 Rejection of invention patent application after publication