|
@@ -25,6 +25,13 @@ import mustache;
|
|
|
alias MustacheEngine!(string) Mustache;
|
|
|
|
|
|
|
|
|
+import vibe.db.postgresql;
|
|
|
+import vibe.data.bson;
|
|
|
+//import vibe.data.json;
|
|
|
+// https://github.com/vibe-d/vibe.d/blob/master/source/vibe/vibe.d
|
|
|
+
|
|
|
+PostgresClient client;
|
|
|
+
|
|
|
|
|
|
/* test unproper arguments order */
|
|
|
/* do not */
|
|
@@ -124,6 +131,26 @@ void hello(HTTPServerRequest req, HTTPServerResponse res){
|
|
|
*/
|
|
|
|
|
|
|
|
|
+void test_pg_conn_driver(){
|
|
|
+ client.pickConnection( (scope conn){
|
|
|
+ immutable result = conn.execStatement(
|
|
|
+ "SELECT 123 as first_num, 567 as second_num, 'abc'::text as third_text " ~
|
|
|
+ "UNION ALL " ~
|
|
|
+ "SELECT 890, 233, 'fgh'::text as third_text",
|
|
|
+ ValueFormat.BINARY
|
|
|
+ );
|
|
|
+
|
|
|
+ assert(result[0]["second_num"].as!PGinteger == 567);
|
|
|
+ assert(result[1]["third_text"].as!PGtext == "fgh");
|
|
|
+
|
|
|
+ foreach (val; rangify(result[0])){
|
|
|
+ writeln("Found entry: ", val.as!Bson.toJson);
|
|
|
+ }
|
|
|
+ } );
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
void test(HTTPServerRequest req, HTTPServerResponse res){
|
|
|
auto cache = memcachedConnect("127.0.0.1:11211");
|
|
|
|
|
@@ -193,6 +220,14 @@ void test(HTTPServerRequest req, HTTPServerResponse res){
|
|
|
|
|
|
|
|
|
|
|
|
+ // https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
|
|
|
+ // https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS
|
|
|
+ //client = new PostgresClient("host=localhost port=5432 dbname=mydb user=usename password=pass connect_timeout=5", 100);
|
|
|
+ client = new PostgresClient("host=195.201.41.112 port=5432 dbname=t4x_parser_data user=admin4 password=Ftsn3rT5YA6ZDWEywfmXekKCS8a4cNxp connect_timeout=5", 100);
|
|
|
+ test_pg_conn_driver();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
Mustache mustache2;
|
|
|
auto context2 = new Mustache.Context;
|
|
|
mustache2.path = "priv/folder2";
|
|
@@ -226,4 +261,3 @@ void test(HTTPServerRequest req, HTTPServerResponse res){
|
|
|
res.writeBody( mustache.render("main", context) );
|
|
|
}
|
|
|
|
|
|
-
|