|
@@ -131,6 +131,7 @@ void hello(HTTPServerRequest req, HTTPServerResponse res){
|
|
|
*/
|
|
|
|
|
|
|
|
|
+/*
|
|
|
void test_pg_conn_driver(){
|
|
|
client.pickConnection( (scope conn){
|
|
|
immutable result = conn.execStatement(
|
|
@@ -148,6 +149,31 @@ void test_pg_conn_driver(){
|
|
|
}
|
|
|
} );
|
|
|
}
|
|
|
+*/
|
|
|
+
|
|
|
+
|
|
|
+string get_all_cities(){
|
|
|
+ return "SELECT id, name, population FROM test ORDER BY id";
|
|
|
+}
|
|
|
+
|
|
|
+void test_pg_conn_driver_queries(){
|
|
|
+
|
|
|
+ client.pickConnection( (scope conn){
|
|
|
+ conn.prepareStatement("get_city_by_id", "SELECT id, name, population FROM test WHERE id = $1"); // get_city_by_id
|
|
|
+ QueryParams params;
|
|
|
+ params.preparedStatementName = "get_city_by_id";
|
|
|
+ params.argsVariadic(3);
|
|
|
+ auto result1 = conn.execPreparedStatement(params);
|
|
|
+
|
|
|
+ writeln("id: ", result1[0]["id"].as!PGinteger);
|
|
|
+ writeln("name: ", result1[0]["name"].as!PGtext);
|
|
|
+ writeln("population: ", result1[0]["population"].as!PGinteger);
|
|
|
+
|
|
|
+ //conn.prepareStatement("q1", "UPDATE test SET name = $1, population = $2 WHERE id = $3"); // update_city_by_id
|
|
|
+ //immutable result1 = conn.execPreparedStatement("", ValueFormat.BINARY);
|
|
|
+
|
|
|
+ } );
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
|
@@ -224,7 +250,8 @@ void test(HTTPServerRequest req, HTTPServerResponse res){
|
|
|
// 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();
|
|
|
+ //test_pg_conn_driver();
|
|
|
+ test_pg_conn_driver_queries();
|
|
|
|
|
|
|
|
|
|