Advertisement
Guest User

Untitled

a guest
Nov 26th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.59 KB | None | 0 0
  1. import vibe.d;
  2. import vibe.db.postgresql;
  3.  
  4. void main() {
  5.     listenHTTP(":8080", &hello);
  6.  
  7.     runApplication();
  8. }
  9.  
  10. void hello(HTTPServerRequest request, HTTPServerResponse response) {
  11.     shared PostgresClient client = new shared PostgresClient("host=localhost dbname=varna user=varna password=varna", 4);
  12.     Answer result;
  13.     {
  14.         auto conn = client.lockConnection();
  15.         result = conn.execStatement("SELECT 2 + 2 AS four", ValueFormat.BINARY);
  16.     }
  17.  
  18.     logInfo("Result: %d", result[0]["four"].as!PGinteger);
  19.  
  20.     response.writeBody("Hello, World: " ~ request.path);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement