Skip to content

manzur/httpQL

Repository files navigation

This project aims to bring SQL and HTTP world together.

Two facts form the base this project:

  • Internet is a big database that contains lots of pages

  • Web-server is nothing more than interpretator that accepts http protocol as a language and produces a web page

So by concluding these two facts it occurs that sql language can be used to model web-client collaboration on top of http.

Let's see some examples how SQL could be used(further on this customized SQL is called httpQL):

Simple queries

HTTP httpQL
GET /index.html HTTP/1.1 select * from index.html
PUT /index.html HTTP/1.1

"File contents"

insert into index.html values("File contents")
POST /index.html HTTP/1.1

"param1=value1&param2=value2"

update index.html set param1 = value1 and param2 = value2
DELETE /index.html HTTP/1.1 delete * from index.html

More sophisticated queries

Select queries can be used to combine http GET request and xpath together. Let's see examples(GET requests in http column are omitted):

XPATH httpQL
//book select book from index.html
/bookstore select .bookstore from index.html
//bookstore/book select bookstore.book from index.html
//bookstore//book select bookstore..book from index.html
//bookstore/book[1] select bookstore.book from index.html where limit book by 1
//bookstore/book[@position < 3] select bookstore.book from index.html where book@position < 3
//bookstore/book[@position=@last()] select bookstore.book from index.html where book@position = @last()
//title[@lang] select title from index.html where title@lang=*
//title[@lang='eng'] select title from index.html where title@lang='eng'
//bookstore/book[@price > 35] select bookstore.book from index.html where book@price > 35
//bookstore/book[@price > 35]/title select bookstore.book.title from index.html where book@price > 35
//bookstore/book/title select bookstore.book.title from index.html
//bookstore/book/price/text() select bookstore.book.price@text from index.html
//host/service[text='DNS'] select host.service from index.html where service@text() = 'DNS'
//network/host[2]/interface/arec/text() select network.host.interface.arec@text() from index.html limit host by 2
//*[@speciality] select * from index.html where *@speciality=*
//degree[@from='Harvard'] select degree from index.html where degree@from='Harvard'
//author[text()='Bob Martin'] select author from index.html where author@text() = 'Bob Martin'
//author[@firstname='Bob' and @lastname='Martin'] select author from index.html where author@firstname='Bob' and author@lastname='Martin'
//*[id='w3c_home_upcoming_events']/ul/li[1]/div[2]/p[1]/a select *.ul.li.div.p.a from index.html where *@id='w3c_home_upcoming_events' and limit li by 1 and limit div by 2 and limit p by 1
//ul[1]//ul[2] select ul..ul from index.html where limit ul#1 by 1 and limit ul#2 by 2

Post-mortem:

Tables give impression that XPATH is simpler and it really is, httpQL contains some artifacts(such #) and less readible. Seperation of concerns did a great job for HTTP and XPath world.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages