serviette

Use json to generate simple sql queries. I needed this for the work project and decided to implement it also in haskell. This could be used to query the database directly from frontend.


Keywords
json, jsontosql, sql, Data.ApiDataTypes, Data.Serviette, hackage, here, haskell, serviette, sql-query
License
BSD-3-Clause
Install
cabal install serviette-0.1.0.6

Documentation

SERVIETTE - JSON to SQL Build Status Hackage

Library for generating SQL queries from JSON. Send the json in the expected format and receive raw sql string.

Why ?

  • Why not ?

Expected JSON format

{
    "format":1,
    "action":"SELECT",
    "selectName": "users",
    "joinTables":[
    	  {"tablename":"addresses","field":"userid","operator":"=","withTable":"users", "withField":"id"},
          {"tablename":"posts","field":"userid","operator":"=","withTable":"users", "withField":"id"}
    	],
    "whereCondition":[
          {"whereTableName":"users","whereField":"id", "whereOperator":">", "whereFieldValue": 1}
      ]
}

If format is set to 1 you will get json response:

{"response":"SELECT users join addresses on userid = users.id  join posts on userid = users.id   where users.id > 1","warnings":"","errors":""}

You can find this lib on hackage Serviette backend is here