CN106708946A - Universal API table query method - Google Patents

Universal API table query method Download PDF

Info

Publication number
CN106708946A
CN106708946A CN201611049717.0A CN201611049717A CN106708946A CN 106708946 A CN106708946 A CN 106708946A CN 201611049717 A CN201611049717 A CN 201611049717A CN 106708946 A CN106708946 A CN 106708946A
Authority
CN
China
Prior art keywords
key
record
name
query
sort
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
CN201611049717.0A
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.)
G Cloud Technology Co Ltd
Original Assignee
G Cloud 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 G Cloud Technology Co Ltd filed Critical G Cloud Technology Co Ltd
Priority to CN201611049717.0A priority Critical patent/CN106708946A/en
Publication of CN106708946A publication Critical patent/CN106708946A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof

Landscapes

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

Abstract

The invention relates to the technical field of databases, and in particular to a universal API table query method. The method mainly comprises the following steps of setting a universal API input format, so as to support fuzzy query according to keywords, provide statistical and page separation functions and support sorting according to a certain field; setting a uniform control logic, so as to only count record numbers or feed the record number and a detailed record list back; and packaging universal statistic and query record functions. Through the universal API table query method, the influences caused by the alternation of table structures to the table query are decreased, the efficiencies of development, test and integration are improved, and the flexible requirements, for the table query, of different businesses are satisfied at the same time.

Description

A kind of table querying method of general API
Technical field
The present invention relates to database technical field, particularly a kind of table querying method of general API.
Background technology
Application system centered on database, inquiry operation is the most frequent;And face to develop, test, integrated work Also be also much on inquiry operation, while the business demand of application system is also dynamic change over time, response Query function can also change, corresponding exploitation, test, it is integrated also want tracking enquiry demand to be adjusted, but how can drop Influence of the low business demand to the programing change of system, reduces the workload of exploitation and O&M
The content of the invention
Present invention solves the technical problem that being to propose a kind of table querying method of general API, the change of table structure is reduced Influence to table inquiry.
The present invention solve above-mentioned technical problem technical scheme be:
Described method is:
(1), general API pattern of the inputs are set, and support carries out fuzzy query according to keyword, there is provided statistics and paging work( Can, support to be sorted according to certain field;
Described API pattern of the inputs:(1) general parameter input is provided:Every page of dominant record number of limit, offset startings Mark, sort_dir sortords, sort_key gives tacit consent to corresponding sort field title, only_static statistical magnitude mark Know, do not put and record in detail, the section list of key_names literary names name section, the multiple fields of support, key_value search keys, Sort_dir spans [asc, desc];(2) in support matrix multiple fields " or " SQL statement fuzzy query;(3) inquire about The corresponding table to be inquired about is specified in the URL of API;
Described statistics is API parameter only_statics parameter values when being true, and a statistical magnitude is specific without inquiry Entry;When API parameter only_statics parameter values are False, specific entry is inquired about;
(2), setting is uniformly controlled logic, realizes a statistic record quantity or feedback record quantity and record list in detail;
Described unified control logic is automatically distributed to specific table statistical function and token record according to interface message In query function, the result of function is combined, feedback record number or record number and detailed page table entry list;
(3) general statistics and inquiry record function, is encapsulated.
The SQL statement of the table statistical function construction statistics is simultaneously performed, final feedback record quantity;The table statistical function Support matrix entity class object, key_names literary name section lists, the input of key_value keyword parameters.
Described table entity class defines table structure and table name;The title of description field, the attribute of field, field takes Value scope, field whether be empty, whether field sets up index.
The SQL statement of the construction statistics is concretely comprised the following steps:
(1) each key_name in key_names literary name section lists obtains the attribute of table entity object, if obtained Get, then carry out SQL query fragment, key_name like%key_value%, most all fragments carry out " or " group at last Close;
(2) table name table_name in table entity class object is obtained, the SQL, select of inquiry table structure is generated count(*)from table_name;
(3) query SQL sentence select count (*) the from table_name where key_ of generation statistics Name1like%key_value%or key_name2like%key_value%or.....
The token record query function construction query SQL is simultaneously inquired about, and finally feeds back detailed page table entry list;Institute State and mark record query function support matrix entity class object, limit, offset sort_dir, sort_key only_static, Key_names, key_value, sort_dir parameter are input into.
The construction query SQL is concretely comprised the following steps:
(1) to be generated according to sort_key and sort_dir parameters, ordering rule SQL fragments, order by sort_key sort_dir;
(2) support the inquiry of paging record, according to parameter limit and offset, generate offset start recordings, offset + limit terminates the query SQL fragment of record;
(3) the record sheet query SQL sentence that sequence, feedback designated recorder start and terminate is supported in generation.
The present invention program's has the beneficial effect that:
General API table inquiry service is provided, the influence that the change of table structure inquire about table is reduced, improve exploitation, test, Integrated efficiency, while meeting the flexible needs that different business is inquired about table.
Brief description of the drawings
The present invention is further described below in conjunction with the accompanying drawings:
Fig. 1 is module map of the invention.
Specific embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete Whole description, it is clear that described embodiment is only a part of embodiment of the invention, rather than whole embodiments.It is based on Embodiment in the present invention, those of ordinary skill in the art are not making the similar approach embodiment of substantive creation, all belong to In the scope of protection of the invention.
As shown in figure 1, the logic that implements each to its separately below is described.
The 1st, API inquiries, every page of dominant record number of |input paramete limit, offset start marks, sort_dir sequences are provided Mode, sort_key gives tacit consent to corresponding sort field title, and only_static statistical magnitude mark does not put record in detail, The section list of key_names literary names name section, supports multiple fields, key_value search keys, sort_dir spans [asc, desc];
Such as:The GET request of API inquiry user's tables users is provided
curl-i-X GET-H″User-Agent:python-client″-H″Content-Type:application/ json″-H″Accept:application/json″-H″X-Auth-Token:$TOKEN_ID″http://node10:8989/ v1.0/users" limit=2&offset=3&sort_key=id&sort_dir=desc&key_names=nam e& Key_names=alias&key_value=test&only_static=false "
Feedback parameter:
REST API are realized especially by the Flask frameworks of Python.
2nd, logic is uniformly controlled, a statistic record quantity or feedback record quantity and in detail record list resolution API is realized Ask to be operated for the GET of users, the users objects table entity Users to be inquired about is obtained, if only_static required parameters For False will call get_table_count functions and get_table_record functions, get_table_ is otherwise only called Count, wherein get_table_count functions;The result that finally encapsulation is counted and inquired about.
False code is as follows:
3rd, get_table_count functions are counted, table entity class, and key_names literary names name section section row will be received Table, key_value search keys, feedback meets the record quantity of inquiry.
Code pseudo-code is described:
4th, get_table_record functions, will receive table entity class, and the section list of key_names literary names name section, Key_value search keys, feedback meets the record quantity of inquiry

Claims (7)

1. a kind of table querying method of general API, it is characterised in that described method is:
(1), general API pattern of the inputs are set, and support carries out fuzzy query according to keyword, there is provided statistics and two-page separation function, Support to be sorted according to certain field;
Described API pattern of the inputs:(1) general parameter input is provided:Every page of dominant record number of limit, offset start marks, Sort_dir sortords, sort_key gives tacit consent to corresponding sort field title, and only_static statistical magnitude is identified, no Record in detail is put, multiple fields, key_value search keys, sort_ are supported in the section list of key_names literary names name section Dir spans [asc, desc];(2) in support matrix multiple fields " or " SQL statement fuzzy query;(3) inquire about API's The corresponding table to be inquired about is specified in URL;
Described statistics is API parameter only_statics parameter values when being true, and a statistical magnitude is without the specific note of inquiry Record item;When API parameter only_statics parameter values are False, specific entry is inquired about;
(2), setting is uniformly controlled logic, realizes a statistic record quantity or feedback record quantity and record list in detail;
Described unified control logic is automatically distributed to specific table statistical function and table record queries according to interface message In function, the result of function is combined, feedback record number or record number and detailed page table entry list;
(3) general statistics and inquiry record function, is encapsulated.
2. method according to claim 1:It is characterized in that:The SQL statement of the table statistical function construction statistics is simultaneously held OK, final feedback record quantity;The table statistical function support matrix entity class object, key_names literary name section lists, key_ Value keyword parameters are input into.
3. method according to claim 2:It is characterized in that:Described table entity class defines table structure and table name; The title of description field, the attribute of field, the span of field, field whether be empty, whether field sets up index.
4. method according to claim 2:It is characterized in that:The SQL statement of the construction statistics is concretely comprised the following steps:
(1) each key_name in key_names literary name section lists obtains the attribute of table entity object, if got , then carry out SQL query fragment, key_name like%key_value%, most all fragments carry out " or " combination at last;
(2) table name table_name in table entity class object is obtained, the SQL, select count (*) of inquiry table structure is generated from table_name;
(3) query SQL sentence select count (*) the from table_name where key_namel of generation statistics Like%key_value%or key_name2like%key_value%or.....
5. method according to claim 3:It is characterized in that:The SQL statement of the construction statistics is concretely comprised the following steps:
(1) each key_name in key_names literary name section lists obtains the attribute of table entity object, if got , then carry out SQL query fragment, key_name like%key_value%, most all fragments carry out " or " combination at last;
(2) table name table_name in table entity class object is obtained, the SQL, select count (*) of inquiry table structure is generated from table_name;
(3) query SQL sentence select count (*) the from table_name where key_name1 of generation statistics Like%key_value%or key_name2 like%key_value%or.....
6. the method according to any one of claim 1 to 5:It is characterized in that:The token record query function construction inquiry SQL is simultaneously inquired about, and finally feeds back detailed page table entry list;The token record query function support matrix entity class object, Limit, offset sort_dir, sort_key only_static, key_names, key_value, sort_dir parameter are defeated Enter.
7. method according to claim 6:It is characterized in that:The construction query SQL is concretely comprised the following steps:
(1) to be generated according to sort_key and sort_dir parameters, ordering rule SQL fragments, order by sort_key sort_dir;
(2) support the inquiry of paging record, according to parameter limit and offset, generate offset start recordings, offset+ Limit terminates the query SQL fragment of record;
(3) the record sheet query SQL sentence that sequence, feedback designated recorder start and terminate is supported in generation.
CN201611049717.0A 2016-11-25 2016-11-25 Universal API table query method Pending CN106708946A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611049717.0A CN106708946A (en) 2016-11-25 2016-11-25 Universal API table query method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611049717.0A CN106708946A (en) 2016-11-25 2016-11-25 Universal API table query method

Publications (1)

Publication Number Publication Date
CN106708946A true CN106708946A (en) 2017-05-24

Family

ID=58934754

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611049717.0A Pending CN106708946A (en) 2016-11-25 2016-11-25 Universal API table query method

Country Status (1)

Country Link
CN (1) CN106708946A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107480280A (en) * 2017-08-22 2017-12-15 金蝶软件(中国)有限公司 The method and relevant device of a kind of data processing
CN109710220A (en) * 2018-12-12 2019-05-03 平安科技(深圳)有限公司 Relevant database querying method, device, equipment and storage medium
CN109739872A (en) * 2018-12-27 2019-05-10 苏州思必驰信息科技有限公司 A kind of implementation method, system and the operating method of SQL statement processing
TWI747371B (en) * 2020-07-10 2021-11-21 財金資訊股份有限公司 Multi-terminal and cross-industry and cross-organization unified specification style application program interface platform and its operation method, computer readable recording medium and computer program product

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101369267A (en) * 2007-08-15 2009-02-18 中兴通讯股份有限公司 Fuzzy query method based on internal memory warehouse
CN105229633A (en) * 2013-03-13 2016-01-06 萨勒斯福斯通讯有限公司 For realizing system, method and apparatus disclosed in data upload, process and predicted query API
CN105589952A (en) * 2015-12-21 2016-05-18 成都科来软件有限公司 General network statistic data querying method and system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101369267A (en) * 2007-08-15 2009-02-18 中兴通讯股份有限公司 Fuzzy query method based on internal memory warehouse
CN105229633A (en) * 2013-03-13 2016-01-06 萨勒斯福斯通讯有限公司 For realizing system, method and apparatus disclosed in data upload, process and predicted query API
CN105589952A (en) * 2015-12-21 2016-05-18 成都科来软件有限公司 General network statistic data querying method and system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
孙风栋等: ""Oracle 10g 数据库海量数据分页查询优化"", 《计算机应用与软件》 *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107480280A (en) * 2017-08-22 2017-12-15 金蝶软件(中国)有限公司 The method and relevant device of a kind of data processing
CN109710220A (en) * 2018-12-12 2019-05-03 平安科技(深圳)有限公司 Relevant database querying method, device, equipment and storage medium
CN109710220B (en) * 2018-12-12 2023-08-22 平安科技(深圳)有限公司 Relational database query method, relational database query device, relational database query equipment and storage medium
CN109739872A (en) * 2018-12-27 2019-05-10 苏州思必驰信息科技有限公司 A kind of implementation method, system and the operating method of SQL statement processing
TWI747371B (en) * 2020-07-10 2021-11-21 財金資訊股份有限公司 Multi-terminal and cross-industry and cross-organization unified specification style application program interface platform and its operation method, computer readable recording medium and computer program product

Similar Documents

Publication Publication Date Title
CN110717319B (en) Self-service report generation method, device, computing equipment and system
CN1764916B (en) Method and apparatus for frequency count
CN106708946A (en) Universal API table query method
US7680781B1 (en) Automatic search query generation and results set management
CN101477526B (en) Method and system for implementing statistical forms customization
CN105930446B (en) A kind of telecom client label generating method based on Hadoop distributed computing technology
CA2484009A1 (en) Managing expressions in a database system
CN102004798B (en) Matching method of symmetrical issuing subscription system based on plural one-dimensional index
CN107679071B (en) Relational database-oriented general data service customized packaging method
CN1301365A (en) Information management system
CN102609421B (en) Data query method and device
US7370030B2 (en) Method to provide management of query output
US20200334314A1 (en) Emergency disposal support system
CN111090674A (en) Search engine system based on hot words and cache
CN101477555B (en) Fast retrieval and generation display method for task tree based on SQL database
CN103729448A (en) Method and device for querying data
CN105975489A (en) Metadata-based online SQL code completion method
CN106341542A (en) Application program management recommendation method and system in mobile phone
CN111209592A (en) Method and system for controlling data authority based on spliced SQL (structured query language) statement
JP2009500760A (en) Method and apparatus for searching in multiple data sources for a selected user community
CN116842255A (en) Accident data management method, visualization system and display method based on metallurgical industry
CN102402515A (en) General custom query system and method
CN1416078A (en) Data processing method of monitoring system
CN105912723A (en) Storage method of custom field
US20100174697A1 (en) System and Methods for Automatic and Interactive Communication with Web Pages

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20170524

RJ01 Rejection of invention patent application after publication