The invention discloses a database query language adaptation method and device, distributed data storage system, including the method of preset label set in advance of database operation and the preset operating rules, based on access to the client according to the preset labels and preset operating rules editing the database related to the operation of the code; according to the preset operation rules and database adapter and analysis of the code, get the database operation language; to realize the operation of the database using the database manipulation language. The difference between the client and the database is blocked so that the client does not need to consider the type of database and the operating language of the database. Similarly, for different operating systems used by clients, only the default tag and default operating rules are required, without the need to unify the language used by the client. Maintain the relative independence between the client and the database. When you change the database, you do not need to modify the client code, which makes the client's code extremely reusable.
【技术实现步骤摘要】
数据库查询语言适配方法及装置、分布式数据存储系统
本专利技术涉及计算机软件领域,具体涉及一种数据库查询语言适配方法及装置。
技术介绍
数据库可以存储和管理数据,还提供给用户所需要的各种数据管理的方式。如支持用户对数据库中存储的数据进行如查询、修改、插入、删除等操作。目前使用的数据库多种多样,有关系型数据库,如Oracle,Mysql,SqlServer等,也有非关系型数据库如MongoDB,CouchDB,DynamoDB,Cassandra等。不同类型数据库使用的数据库语言也各不同。关系型数据库在进行数据查询时使用标准的结构化查询语言(StructuredQueryLanguage),而非关系型数据库则主要基于各自定义的领域专用语言(DSL,domainspecificlanguage)。由于不同数据库使用的语言不一致,这样可能导致在数据库发生更换时,往往需要将之前使用的数据库语言相关的代码、逻辑进行修改,重新测试等,需要花费很多的时间和人力,其工作量巨大。例如,数据库由Mysql迁移到MongoDB,原客户端的所有与数据库相关的如查询、修改、插入、删除等操作相关的代码、逻辑都需要进行修改,从而带来庞大的工作量。且在修改后还需要在进行测试等工作,耗费巨大的人力、物力和时间。
技术实现思路
鉴于上述问题,提出了本专利技术以便提供一种克服上述问题或者至少部分地解决上述问题的数据库查询语言适配方法及装置。根据本专利技术的一个方面,提供了一种数据库查询语言适配方法,方法基于预先设置的数据库操作的预设标签和预设操作规则实现,方法包括:获取客户端按照预设标签和预设操作规 ...
【技术保护点】
一种数据库查询语言适配方法,所述方法基于预先设置的数据库操作的预设标签和预设操作规则实现,所述方法包括:获取客户端按照所述预设标签和所述预设操作规则所编辑的数据库操作相关的代码;根据所述预设操作规则和数据库适配器,对所述代码进行解析,得到数据库的操作语言;利用所述数据库的操作语言实现对数据库的操作。
【技术特征摘要】
1.一种数据库查询语言适配方法,所述方法基于预先设置的数据库操作的预设标签和预设操作规则实现,所述方法包括:获取客户端按照所述预设标签和所述预设操作规则所编辑的数据库操作相关的代码;根据所述预设操作规则和数据库适配器,对所述代码进行解析,得到数据库的操作语言;利用所述数据库的操作语言实现对数据库的操作。2.根据权利要求1所述的方法,其中,所述数据库操作的预设标签包括数据库名称、数据表名称、操作类型、查询参数集合和/或数据值集合。3.根据权利要求2所述的方法,其中,所述操作类型包括查询、更新、插入、删除和/或自定义操作。4.根据权利要求2所述的方法,其中,所述查询参数集合包括函数集合、分页、排序、分组和/或条件集合。5.根据权利要求1所述的方法,其中,所述数据库包括关系型数据库和/或非关系型数据库。6.根据权利要求1所述的方法,其中,所述代码基于json语言实现。7.根据权利要求1-6任一项所述的方法,其中,所述根据所述预...
【专利技术属性】
技术研发人员:徐锐波,程卓,
申请(专利权)人:北京奇虎科技有限公司,
类型:发明
国别省市:北京,11
还没有人留言评论。发表了对其他浏览者有用的留言会获得科技券。