|
@@ -30,7 +30,7 @@ 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 */
|
|
@@ -81,11 +81,21 @@ string test_args_types_mismash2(test_key3 x, test_key4 y){
|
|
|
|
|
|
|
|
|
|
|
|
+PostgresClient client;
|
|
|
+
|
|
|
+
|
|
|
void main(){
|
|
|
auto settings = new HTTPServerSettings;
|
|
|
settings.port = 8080;
|
|
|
settings.bindAddresses = ["::1", "127.0.0.1"];
|
|
|
|
|
|
+
|
|
|
+ // 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", 20);
|
|
|
+ client = new PostgresClient("host=195.201.41.112 port=5432 dbname=t4x_parser_data user=admin4 password=Ftsn3rT5YA6ZDWEywfmXekKCS8a4cNxp connect_timeout=5", 20);
|
|
|
+
|
|
|
+
|
|
|
//auto fsettings = new HTTPFileServerSettings;
|
|
|
//fsettings.serverPathPrefix = "/static";
|
|
|
|
|
@@ -158,6 +168,7 @@ string get_all_cities(){
|
|
|
|
|
|
void test_pg_conn_driver_queries(){
|
|
|
|
|
|
+ /*
|
|
|
client.pickConnection( (scope conn){
|
|
|
QueryParams params; // https://github.com/denizzzka/dpq2/blob/master/src/dpq2/args.d#L15
|
|
|
params.preparedStatementName = "get_city_by_id";
|
|
@@ -172,10 +183,39 @@ void test_pg_conn_driver_queries(){
|
|
|
//conn.prepareEx("q1", "UPDATE test SET name = $1, population = $2 WHERE id = $3"); // update_city_by_id
|
|
|
//immutable result1 = conn.execPrepared("", ValueFormat.BINARY);
|
|
|
|
|
|
+ destroy(conn);
|
|
|
+
|
|
|
} );
|
|
|
+ */
|
|
|
+
|
|
|
+ auto conn = client.lockConnection();
|
|
|
+ QueryParams params; // https://github.com/denizzzka/dpq2/blob/master/src/dpq2/args.d#L15
|
|
|
+ params.preparedStatementName = "get_city_by_id";
|
|
|
+ params.argsVariadic(3); // https://github.com/denizzzka/dpq2/blob/master/example/example.d#L42 // https://github.com/denizzzka/dpq2/blob/master/src/dpq2/query.d#L336 // https://github.com/denizzzka/vibe.d.db.postgresql/blob/master/source/vibe/db/postgresql/package.d#L423
|
|
|
+ conn.prepareEx(params.preparedStatementName, "SELECT id, name, population FROM test WHERE id = $1"); // get_city_by_id
|
|
|
+ auto result1 = conn.execPrepared(params);
|
|
|
+
|
|
|
+ writeln("id: ", result1[0]["id"].as!PGinteger);
|
|
|
+ writeln("name: ", result1[0]["name"].as!PGtext);
|
|
|
+ writeln("population: ", result1[0]["population"].as!PGinteger);
|
|
|
+
|
|
|
+ //conn.prepareEx("q1", "UPDATE test SET name = $1, population = $2 WHERE id = $3"); // update_city_by_id
|
|
|
+ //immutable result1 = conn.execPrepared("", ValueFormat.BINARY);
|
|
|
+
|
|
|
+ destroy(conn);
|
|
|
}
|
|
|
|
|
|
|
|
|
+/*
|
|
|
+
|
|
|
+"SELECT id, name, population FROM test ORDER BY id"
|
|
|
+"UPDATE test SET name = $1, population = $2 WHERE id = $3", [City_Name, City_Pop, City_Id]
|
|
|
+"INSERT INTO test (name, population) VALUES ($1, $2)", [City_Name, City_Pop]
|
|
|
+"INSERT INTO test (name, population) VALUES ($1, $2) RETURNING id", [City_Name, City_Pop]
|
|
|
+"DELETE FROM test WHERE id = $1", [City_Id]
|
|
|
+
|
|
|
+*/
|
|
|
+
|
|
|
|
|
|
void test(HTTPServerRequest req, HTTPServerResponse res){
|
|
|
auto cache = memcachedConnect("127.0.0.1:11211");
|
|
@@ -246,10 +286,6 @@ 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();
|
|
|
test_pg_conn_driver_queries();
|
|
|
|