Skip to content

A microservice for talking to PostgreSQL instances

Notifications You must be signed in to change notification settings

viastakhov/clj-pg-query

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clj-pg-query

A microservice written in Clojure for talking to PostgreSQL instances.

Key features

  • A RESTfull microservice;
  • Define a JDBC datasource using POST method;
  • Execute SELECT statement using POST method;
  • Execute INSERT statement using POST method;
  • Execute UPDATE statement using PUT method;
  • Execute DELETE statement using DELETE method;
  • Swagger UI.

Swagger UI

Swagger UI

How-to

Based on PleaseFoundation/PG

Define a JDBC datasource

POST /v1/datasource/define DatasourceConfig:

{
  "host": "127.0.0.1",
  "port": 5432,
  "database": "postgres",
  "username": "postgres",
  "password": "P@ssw0rd!"
}

Selects - DSL for simple select queries

POST /v1/statement/select

Table: pg_amop

Where:

{
  "amopopr": 522
}

Updates - DSL for updating data

PUT /v1/statement/update

Table: pg_amop

Clause:

{
  "columns": {"amoplefttype": 44,
              "amoppurpose": "j"},
  "where": {"amopfamily": "46"}
}

Inserts - DSL for inserting data

INSERT /v1/statement/insert

Table: pg_amop

Data:

{
  "amopfamily": "46",
  "amoplefttype": "234",
  "amoprighttype": "4565",
  "amopstrategy": "222",
  "amoppurpose": "s",
  "amopopr": "98",
  "amopmethod": "44",
  "amopsortfamily": "99"
}

Deletes - DSL for deleting data

DELETE /v1/statement/delete

Table: pg_amop

Where:

{
  "amoplefttype": 33
}

Prerequisites

You will need Leiningen 2.0.0 or above installed.

Running

To start a web server for the application, run:

lein ring server

License

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

A microservice for talking to PostgreSQL instances

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published