SQL to anything (s2x)

s2x converts SQL functions calls to a variety of formats

s2x is accessed over HTTP. SQL function names and parameters are passed inside HTTP requests.

Multiple calls can be chained into one HTTP request to avoid database round-trips.

Details:

Example

Write a SQL function in PostgreSQL (e.g. listProductNames)

CREATE FUNCTION listProductNames() RETURNS SETOF varchar AS $$
   SELECT name FROM Products;
$$ LANGUAGE 'SQL';

To get the result set in the format of your choice (JSON, XML, CSV, XLSX):

SQL to JSON

curl http://s2x.co/listProductNames.json
{"listProductNames":[{"name":"Snow blower"},{"name":"Cordless drill"}]}

SQL to XML

curl http://s2x.co/listProductNames.xml
<sql2xml>
  <function name="listProductNames">
    <set>
      <record><value name="name">Snow blower</value></record>
      <record><value name="name">Cordless drill</value></record>
    </set>
  </function>
</sql2xml>

SQL to csv (comma-separated-values)

curl http://s2x.co/listProductNames.csv
"name"
"Snow blower"
"Cordless drill"

SQL to Excel (Office Open XML)

curl http://s2x.co/listProductNames.xlsx