diff --git a/run/libpq_create_db.run b/run/libpq_create_db.run
new file mode 100644
index 0000000..6457655
--- /dev/null
+++ b/run/libpq_create_db.run
@@ -0,0 +1,113 @@
+#
+# Build
+#
+
+set build_components {
+ core
+ init
+ drivers/timer
+ test/libpq/db_create
+}
+
+lappend_if [have_spec usb] build_components drivers/usb
+lappend_if [have_spec gpio] build_components drivers/gpio
+
+source ${genode_dir}/repos/base/run/platform_drv.inc
+append_platform_drv_build_components
+
+build $build_components
+
+create_boot_directory
+
+#
+# Generate config
+#
+
+append config {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ }
+
+append_platform_drv_config
+
+append_if [have_spec gpio] config {
+
+
+
+
+ }
+
+append config {
+
+
+
+
+
+
+
+ }
+
+append config {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+install_config $config
+
+#
+# Boot modules
+#
+
+
+append boot_modules {
+ core init
+ timer
+ test-libpq_create
+ ld.lib.so
+ libc.lib.so
+ libpq.lib.so
+ lwip.lib.so
+ libm.lib.so
+ pthread.lib.so
+ stdcxx.lib.so
+}
+
+lappend_if [have_spec usb] boot_modules usb_drv
+lappend_if [have_spec gpio] boot_modules gpio_drv
+
+append_platform_drv_boot_modules
+
+build_boot_image $boot_modules
+
+append qemu_args " -m 256"
+
+run_genode_until forever
+
diff --git a/run/libpq_createdb_db.run b/run/libpq_createdb_db.run
new file mode 100644
index 0000000..a07c70e
--- /dev/null
+++ b/run/libpq_createdb_db.run
@@ -0,0 +1,115 @@
+#
+# Build
+#
+
+set build_components {
+ core
+ init
+ drivers/timer
+ test/libpq/db_createdb
+}
+
+lappend_if [have_spec usb] build_components drivers/usb
+lappend_if [have_spec gpio] build_components drivers/gpio
+
+source ${genode_dir}/repos/base/run/platform_drv.inc
+append_platform_drv_build_components
+
+build $build_components
+
+create_boot_directory
+
+#
+# Generate config
+#
+
+append config {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ }
+
+append_platform_drv_config
+
+append_if [have_spec gpio] config {
+
+
+
+
+ }
+
+append config {
+
+
+
+
+
+
+
+ }
+
+append config {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+install_config $config
+
+#
+# Boot modules
+#
+
+# The QtQuick plugin currently needs to be provided both in the file system
+# (for Qt) and as ROM module (for 'dlopen()').
+
+append boot_modules {
+ core init
+ timer
+ test-libpq_createdb
+ ld.lib.so
+ libc.lib.so
+ libpq.lib.so
+ lwip.lib.so
+ libm.lib.so
+ pthread.lib.so
+ stdcxx.lib.so
+}
+
+lappend_if [have_spec usb] boot_modules usb_drv
+lappend_if [have_spec gpio] boot_modules gpio_drv
+
+append_platform_drv_boot_modules
+
+build_boot_image $boot_modules
+
+append qemu_args " -m 256"
+
+run_genode_until forever
+
diff --git a/run/libpq_list_db.run b/run/libpq_list_db.run
new file mode 100644
index 0000000..844fc29
--- /dev/null
+++ b/run/libpq_list_db.run
@@ -0,0 +1,112 @@
+#
+# Build
+#
+
+set build_components {
+ core
+ init
+ drivers/timer
+ test/libpq/db_list
+}
+
+lappend_if [have_spec usb] build_components drivers/usb
+lappend_if [have_spec gpio] build_components drivers/gpio
+
+source ${genode_dir}/repos/base/run/platform_drv.inc
+append_platform_drv_build_components
+
+build $build_components
+
+create_boot_directory
+
+#
+# Generate config
+#
+
+append config {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ }
+
+append_platform_drv_config
+
+append_if [have_spec gpio] config {
+
+
+
+
+ }
+
+append config {
+
+
+
+
+
+
+
+ }
+
+append config {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+install_config $config
+
+#
+# Boot modules
+#
+
+append boot_modules {
+ core init
+ timer
+ test-libpq_list_db
+ ld.lib.so
+ libc.lib.so
+ libpq.lib.so
+ lwip.lib.so
+ libm.lib.so
+ pthread.lib.so
+ stdcxx.lib.so
+}
+
+lappend_if [have_spec usb] boot_modules usb_drv
+lappend_if [have_spec gpio] boot_modules gpio_drv
+
+append_platform_drv_boot_modules
+
+build_boot_image $boot_modules
+
+append qemu_args " -m 256"
+
+run_genode_until forever
+
diff --git a/run/libpq_update_db.run b/run/libpq_update_db.run
new file mode 100644
index 0000000..14026ad
--- /dev/null
+++ b/run/libpq_update_db.run
@@ -0,0 +1,113 @@
+#
+# Build
+#
+
+set build_components {
+ core
+ init
+ drivers/timer
+ test/libpq/db_update
+}
+
+lappend_if [have_spec usb] build_components drivers/usb
+lappend_if [have_spec gpio] build_components drivers/gpio
+
+source ${genode_dir}/repos/base/run/platform_drv.inc
+append_platform_drv_build_components
+
+build $build_components
+
+create_boot_directory
+
+#
+# Generate config
+#
+
+append config {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ }
+
+append_platform_drv_config
+
+append_if [have_spec gpio] config {
+
+
+
+
+ }
+
+append config {
+
+
+
+
+
+
+
+ }
+
+append config {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+install_config $config
+
+#
+# Boot modules
+#
+
+
+append boot_modules {
+ core init
+ timer
+ test-libpq_update
+ ld.lib.so
+ libc.lib.so
+ libpq.lib.so
+ lwip.lib.so
+ libm.lib.so
+ pthread.lib.so
+ stdcxx.lib.so
+}
+
+lappend_if [have_spec usb] boot_modules usb_drv
+lappend_if [have_spec gpio] boot_modules gpio_drv
+
+append_platform_drv_boot_modules
+
+build_boot_image $boot_modules
+
+append qemu_args " -m 256"
+
+run_genode_until forever
+
diff --git a/run/libpqxx_conection.run b/run/libpqxx_conection.run
new file mode 100644
index 0000000..c3b6daa
--- /dev/null
+++ b/run/libpqxx_conection.run
@@ -0,0 +1,113 @@
+#
+# Build
+#
+
+set build_components {
+ core
+ init
+ drivers/timer
+ test/libpqxx/conection_test
+}
+
+lappend_if [have_spec usb] build_components drivers/usb
+lappend_if [have_spec gpio] build_components drivers/gpio
+
+source ${genode_dir}/repos/base/run/platform_drv.inc
+append_platform_drv_build_components
+
+build $build_components
+
+create_boot_directory
+
+#
+# Generate config
+#
+
+append config {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ }
+
+append_platform_drv_config
+
+append_if [have_spec gpio] config {
+
+
+
+
+ }
+
+append config {
+
+
+
+
+
+
+
+ }
+
+append config {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+install_config $config
+
+#
+# Boot modules
+#
+
+append boot_modules {
+ core init
+ timer
+ test-conection
+ ld.lib.so
+ libc.lib.so
+ libpq.lib.so
+ libpqxx.lib.so
+ lwip.lib.so
+ libm.lib.so
+ pthread.lib.so
+ stdcxx.lib.so
+}
+
+lappend_if [have_spec usb] boot_modules usb_drv
+lappend_if [have_spec gpio] boot_modules gpio_drv
+
+append_platform_drv_boot_modules
+
+build_boot_image $boot_modules
+
+append qemu_args " -m 256"
+
+run_genode_until forever
+
diff --git a/run/libpqxx_creation_table.run b/run/libpqxx_creation_table.run
new file mode 100644
index 0000000..eeb7251
--- /dev/null
+++ b/run/libpqxx_creation_table.run
@@ -0,0 +1,113 @@
+#
+# Build
+#
+
+set build_components {
+ core
+ init
+ drivers/timer
+ test/libpqxx/creation_table
+}
+
+lappend_if [have_spec usb] build_components drivers/usb
+lappend_if [have_spec gpio] build_components drivers/gpio
+
+source ${genode_dir}/repos/base/run/platform_drv.inc
+append_platform_drv_build_components
+
+build $build_components
+
+create_boot_directory
+
+#
+# Generate config
+#
+
+append config {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ }
+
+append_platform_drv_config
+
+append_if [have_spec gpio] config {
+
+
+
+
+ }
+
+append config {
+
+
+
+
+
+
+
+ }
+
+append config {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+install_config $config
+
+#
+# Boot modules
+#
+
+append boot_modules {
+ core init
+ timer
+ test-creation_table
+ ld.lib.so
+ libc.lib.so
+ libpq.lib.so
+ libpqxx.lib.so
+ lwip.lib.so
+ libm.lib.so
+ pthread.lib.so
+ stdcxx.lib.so
+}
+
+lappend_if [have_spec usb] boot_modules usb_drv
+lappend_if [have_spec gpio] boot_modules gpio_drv
+
+append_platform_drv_boot_modules
+
+build_boot_image $boot_modules
+
+append qemu_args " -m 256"
+
+run_genode_until forever
+
diff --git a/run/libpqxx_delete_operation.run b/run/libpqxx_delete_operation.run
new file mode 100644
index 0000000..bfa7a9f
--- /dev/null
+++ b/run/libpqxx_delete_operation.run
@@ -0,0 +1,113 @@
+#
+# Build
+#
+
+set build_components {
+ core
+ init
+ drivers/timer
+ test/libpqxx/delete_operation
+}
+
+lappend_if [have_spec usb] build_components drivers/usb
+lappend_if [have_spec gpio] build_components drivers/gpio
+
+source ${genode_dir}/repos/base/run/platform_drv.inc
+append_platform_drv_build_components
+
+build $build_components
+
+create_boot_directory
+
+#
+# Generate config
+#
+
+append config {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ }
+
+append_platform_drv_config
+
+append_if [have_spec gpio] config {
+
+
+
+
+ }
+
+append config {
+
+
+
+
+
+
+
+ }
+
+append config {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+install_config $config
+
+#
+# Boot modules
+#
+
+append boot_modules {
+ core init
+ timer
+ test-delete_operation
+ ld.lib.so
+ libc.lib.so
+ libpq.lib.so
+ libpqxx.lib.so
+ lwip.lib.so
+ libm.lib.so
+ pthread.lib.so
+ stdcxx.lib.so
+}
+
+lappend_if [have_spec usb] boot_modules usb_drv
+lappend_if [have_spec gpio] boot_modules gpio_drv
+
+append_platform_drv_boot_modules
+
+build_boot_image $boot_modules
+
+append qemu_args " -m 256"
+
+run_genode_until forever
+
diff --git a/run/libpqxx_insert_operation.run b/run/libpqxx_insert_operation.run
new file mode 100644
index 0000000..6bcba9a
--- /dev/null
+++ b/run/libpqxx_insert_operation.run
@@ -0,0 +1,116 @@
+#
+# Build
+#
+
+set build_components {
+ core
+ init
+ drivers/timer
+ test/libpqxx/insert_operation
+}
+
+lappend_if [have_spec usb] build_components drivers/usb
+lappend_if [have_spec gpio] build_components drivers/gpio
+
+source ${genode_dir}/repos/base/run/platform_drv.inc
+append_platform_drv_build_components
+
+build $build_components
+
+create_boot_directory
+
+#
+# Generate config
+#
+
+append config {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ }
+
+append_platform_drv_config
+
+append_if [have_spec gpio] config {
+
+
+
+
+ }
+
+append config {
+
+
+
+
+
+
+
+ }
+
+append config {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+install_config $config
+
+#
+# Boot modules
+#
+
+# The QtQuick plugin currently needs to be provided both in the file system
+# (for Qt) and as ROM module (for 'dlopen()').
+
+append boot_modules {
+ core init
+ timer
+ test-insert_operation
+ ld.lib.so
+ libc.lib.so
+ libpq.lib.so
+ libpqxx.lib.so
+ lwip.lib.so
+ libm.lib.so
+ pthread.lib.so
+ stdcxx.lib.so
+}
+
+lappend_if [have_spec usb] boot_modules usb_drv
+lappend_if [have_spec gpio] boot_modules gpio_drv
+
+append_platform_drv_boot_modules
+
+build_boot_image $boot_modules
+
+append qemu_args " -m 256"
+
+run_genode_until forever
+
diff --git a/run/libpqxx_select_operation.run b/run/libpqxx_select_operation.run
new file mode 100644
index 0000000..fc82fd9
--- /dev/null
+++ b/run/libpqxx_select_operation.run
@@ -0,0 +1,113 @@
+#
+# Build
+#
+
+set build_components {
+ core
+ init
+ drivers/timer
+ test/libpqxx/select_operation
+}
+
+lappend_if [have_spec usb] build_components drivers/usb
+lappend_if [have_spec gpio] build_components drivers/gpio
+
+source ${genode_dir}/repos/base/run/platform_drv.inc
+append_platform_drv_build_components
+
+build $build_components
+
+create_boot_directory
+
+#
+# Generate config
+#
+
+append config {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ }
+
+append_platform_drv_config
+
+append_if [have_spec gpio] config {
+
+
+
+
+ }
+
+append config {
+
+
+
+
+
+
+
+ }
+
+append config {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+install_config $config
+
+#
+# Boot modules
+#
+
+append boot_modules {
+ core init
+ timer
+ test-select_operation
+ ld.lib.so
+ libc.lib.so
+ libpq.lib.so
+ libpqxx.lib.so
+ lwip.lib.so
+ libm.lib.so
+ pthread.lib.so
+ stdcxx.lib.so
+}
+
+lappend_if [have_spec usb] boot_modules usb_drv
+lappend_if [have_spec gpio] boot_modules gpio_drv
+
+append_platform_drv_boot_modules
+
+build_boot_image $boot_modules
+
+append qemu_args " -m 256"
+
+run_genode_until forever
+
diff --git a/run/libpqxx_update_operation.run b/run/libpqxx_update_operation.run
new file mode 100644
index 0000000..4e4db00
--- /dev/null
+++ b/run/libpqxx_update_operation.run
@@ -0,0 +1,116 @@
+#
+# Build
+#
+
+set build_components {
+ core
+ init
+ drivers/timer
+ test/libpqxx/update_operation
+}
+
+lappend_if [have_spec usb] build_components drivers/usb
+lappend_if [have_spec gpio] build_components drivers/gpio
+
+source ${genode_dir}/repos/base/run/platform_drv.inc
+append_platform_drv_build_components
+
+build $build_components
+
+create_boot_directory
+
+#
+# Generate config
+#
+
+append config {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ }
+
+append_platform_drv_config
+
+append_if [have_spec gpio] config {
+
+
+
+
+ }
+
+append config {
+
+
+
+
+
+
+
+ }
+
+append config {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+
+install_config $config
+
+#
+# Boot modules
+#
+
+# The QtQuick plugin currently needs to be provided both in the file system
+# (for Qt) and as ROM module (for 'dlopen()').
+
+append boot_modules {
+ core init
+ timer
+ test-update_operation
+ ld.lib.so
+ libc.lib.so
+ libpq.lib.so
+ libpqxx.lib.so
+ lwip.lib.so
+ libm.lib.so
+ pthread.lib.so
+ stdcxx.lib.so
+}
+
+lappend_if [have_spec usb] boot_modules usb_drv
+lappend_if [have_spec gpio] boot_modules gpio_drv
+
+append_platform_drv_boot_modules
+
+build_boot_image $boot_modules
+
+append qemu_args " -m 256"
+
+run_genode_until forever
+
diff --git a/src/lib/libpq/dummy_sig_method.c b/src/lib/libpq/dummy_sig_method.c
new file mode 100644
index 0000000..e843e84
--- /dev/null
+++ b/src/lib/libpq/dummy_sig_method.c
@@ -0,0 +1,30 @@
+/*
+ * \brief Dummy implementations
+ * \author Reinier Millo Sánchez
+ * \author Alexy Gallardo Segura
+ * \date 2015-11-15
+ */
+
+/*
+ * Copyright (C) 2015 Genode Labs GmbH
+ *
+ * This file is part of the Genode OS framework, which is distributed
+ * under the terms of the GNU General Public License version 2.
+ */
+
+#include
+
+int sigpending(sigset_t *set)
+{
+ //*sig = SIGQUIT;
+ return 0;
+}
+
+
+int sigwait(const sigset_t *set, int *sig)
+{
+ *sig = SIGQUIT;
+ return 0;
+}
+
+
diff --git a/src/test/libpq/db_create/main.cc b/src/test/libpq/db_create/main.cc
new file mode 100644
index 0000000..d5466f0
--- /dev/null
+++ b/src/test/libpq/db_create/main.cc
@@ -0,0 +1,121 @@
+/**
+* This example was taken of the article "PostgreSQL C tutorial" on the url next.
+* URL=http://zetcode.com/db/postgresqlc/
+*/
+
+#include
+#include
+#include
+
+void do_exit(PGconn *conn, PGresult *res) {
+
+ fprintf(stderr, "%s\n", PQerrorMessage(conn));
+
+ PQclear(res);
+ PQfinish(conn);
+
+ exit(1);
+}
+
+int main(int argc, char **argv) {
+ const char *conninfo;
+
+ if (argc > 0)
+ conninfo = argv[0];
+ else
+ conninfo = "dbname=postgres";
+
+ PGconn *conn = PQconnectdb(conninfo);
+
+ if (PQstatus(conn) == CONNECTION_BAD) {
+
+ fprintf(stderr, "Connection to database failed: %s\n",
+ PQerrorMessage(conn));
+
+ PQfinish(conn);
+ exit(1);
+ }
+
+ PGresult *res = PQexec(conn, "DROP TABLE IF EXISTS Cars");
+
+ if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+ do_exit(conn, res);
+ }
+
+ PQclear(res);
+
+ res = PQexec(conn, "CREATE TABLE Cars(Id INTEGER PRIMARY KEY," \
+ "Name VARCHAR(20), Price INT)");
+
+ if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+ do_exit(conn, res);
+ }
+
+ PQclear(res);
+
+ res = PQexec(conn, "INSERT INTO Cars VALUES(1,'Audi',52642)");
+
+ if (PQresultStatus(res) != PGRES_COMMAND_OK)
+ do_exit(conn, res);
+
+ PQclear(res);
+
+ res = PQexec(conn, "INSERT INTO Cars VALUES(2,'Mercedes',57127)");
+
+ if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+ do_exit(conn, res);
+ }
+
+ PQclear(res);
+
+ res = PQexec(conn, "INSERT INTO Cars VALUES(3,'Skoda',9000)");
+
+ if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+ do_exit(conn, res);
+ }
+
+ PQclear(res);
+
+ res = PQexec(conn, "INSERT INTO Cars VALUES(4,'Volvo',29000)");
+
+ if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+ do_exit(conn, res);
+ }
+
+ PQclear(res);
+
+ res = PQexec(conn, "INSERT INTO Cars VALUES(5,'Bentley',350000)");
+
+ if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+ do_exit(conn, res);
+ }
+
+ PQclear(res);
+
+ res = PQexec(conn, "INSERT INTO Cars VALUES(6,'Citroen',21000)");
+
+ if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+ do_exit(conn, res);
+ }
+
+ PQclear(res);
+
+ res = PQexec(conn, "INSERT INTO Cars VALUES(7,'Hummer',41400)");
+
+ if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+ do_exit(conn, res);
+ }
+
+ PQclear(res);
+
+ res = PQexec(conn, "INSERT INTO Cars VALUES(8,'Volkswagen',21600)");
+
+ if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+ do_exit(conn, res);
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ return 0;
+}
diff --git a/src/test/libpq/db_create/target.mk b/src/test/libpq/db_create/target.mk
new file mode 100644
index 0000000..44b4eeb
--- /dev/null
+++ b/src/test/libpq/db_create/target.mk
@@ -0,0 +1,3 @@
+TARGET = test-libpq_create
+SRC_CC = main.cc
+LIBS += base stdcxx libc-net lwip libc_lwip libc_lwip_nic_dhcp libc_lwip_loopback libc libpq config_args
diff --git a/src/test/libpq/db_createdb/main.cc b/src/test/libpq/db_createdb/main.cc
new file mode 100644
index 0000000..488e84d
--- /dev/null
+++ b/src/test/libpq/db_createdb/main.cc
@@ -0,0 +1,49 @@
+/**
+* This example was taken of the article "PostgreSQL C tutorial" on the url next.
+* URL=http://zetcode.com/db/postgresqlc/
+*/
+
+#include
+#include
+#include
+
+void do_exit(PGconn *conn, PGresult *res) {
+
+ fprintf(stderr, "%s\n", PQerrorMessage(conn));
+
+ PQclear(res);
+ PQfinish(conn);
+
+ exit(1);
+}
+
+int main(int argc, char **argv) {
+ const char *conninfo;
+
+ if (argc > 0)
+ conninfo = argv[0];
+ else
+ conninfo = "dbname=postgres";
+
+ PGconn *conn = PQconnectdb(conninfo);
+
+ if (PQstatus(conn) == CONNECTION_BAD) {
+
+ fprintf(stderr, "Connection to database failed: %s\n",
+ PQerrorMessage(conn));
+
+ PQfinish(conn);
+ exit(1);
+ }
+
+ PGresult *res = PQexec(conn, "CREATE DATABASE baseDBTest;");
+
+ if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+ do_exit(conn, res);
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ return 0;
+}
diff --git a/src/test/libpq/db_createdb/target.mk b/src/test/libpq/db_createdb/target.mk
new file mode 100644
index 0000000..ab04712
--- /dev/null
+++ b/src/test/libpq/db_createdb/target.mk
@@ -0,0 +1,3 @@
+TARGET = test-libpq_createdb
+SRC_CC = main.cc
+LIBS += base stdcxx libc-net lwip libc_lwip libc_lwip_nic_dhcp libc_lwip_loopback libc libpq config_args
diff --git a/src/test/libpq/db_list/main.cc b/src/test/libpq/db_list/main.cc
new file mode 100644
index 0000000..d9f4db6
--- /dev/null
+++ b/src/test/libpq/db_list/main.cc
@@ -0,0 +1,129 @@
+/*
+ * testlibpq.c
+ *
+ * Test the C version of libpq, the PostgreSQL frontend library.
+ *
+ * This example is taken of official documentation web of Postgres for using libpq.
+ *
+ * URL=http://www.postgresql.org/docs/9.1/static/libpq-example.html
+ */
+
+#include
+
+#include
+#include
+#include
+
+
+static void
+exit_nicely(PGconn *conn)
+{
+ PQfinish(conn);
+ exit(1);
+}
+
+int
+main(int argc, char **argv)
+{
+ const char *conninfo;
+ PGconn *conn;
+ PGresult *res;
+ int nFields;
+ int i,
+ j;
+
+ /*
+ * If the user supplies a parameter on the command line, use it as the
+ * conninfo string; otherwise default to setting dbname=postgres and using
+ * environment variables or defaults for all other connection parameters.
+ */
+ if (argc > 0)
+ conninfo = argv[0];
+ else
+ conninfo = "dbname=postgres";
+
+ /* Make a connection to the database */
+ conn = PQconnectdb(conninfo);
+
+ /* Check to see that the backend connection was successfully made */
+ if (PQstatus(conn) != CONNECTION_OK)
+ {
+ fprintf(stderr, "Connection to database failed: %s",
+ PQerrorMessage(conn));
+ exit_nicely(conn);
+ }
+
+
+ /*
+ * Our test case here involves using a cursor, for which we must be inside
+ * a transaction block. We could do the whole thing with a single
+ * PQexec() of "select * from pg_database", but that's too trivial to make
+ * a good example.
+ */
+
+ /* Start a transaction block */
+ res = PQexec(conn, "BEGIN");
+ if (PQresultStatus(res) != PGRES_COMMAND_OK)
+ {
+ fprintf(stderr, "BEGIN command failed: %s", PQerrorMessage(conn));
+ PQclear(res);
+ exit_nicely(conn);
+ }
+
+ /*
+ * Should PQclear PGresult whenever it is no longer needed to avoid memory
+ * leaks
+ */
+
+ PQclear(res);
+
+
+ /*
+ * Fetch rows from pg_database, the system catalog of databases
+ */
+ res = PQexec(conn, "DECLARE myportal CURSOR FOR select * from pg_database");
+ if (PQresultStatus(res) != PGRES_COMMAND_OK)
+ {
+ fprintf(stderr, "DECLARE CURSOR failed: %s", PQerrorMessage(conn));
+ PQclear(res);
+ exit_nicely(conn);
+ }
+ PQclear(res);
+
+ res = PQexec(conn, "FETCH ALL in myportal");
+ if (PQresultStatus(res) != PGRES_TUPLES_OK)
+ {
+ fprintf(stderr, "FETCH ALL failed: %s", PQerrorMessage(conn));
+ PQclear(res);
+ exit_nicely(conn);
+ }
+
+ /* first, print out the attribute names */
+ nFields = PQnfields(res);
+ for (i = 0; i < nFields; i++)
+ printf("%-15s", PQfname(res, i));
+ printf("\n\n");
+
+ /* next, print out the rows */
+ for (i = 0; i < PQntuples(res); i++)
+ {
+ for (j = 0; j < nFields; j++)
+ printf("%-15s", PQgetvalue(res, i, j));
+ printf("\n");
+ }
+
+ PQclear(res);
+
+ /* close the portal ... we don't bother to check for errors ... */
+ res = PQexec(conn, "CLOSE myportal");
+ PQclear(res);
+
+ /* end the transaction */
+ res = PQexec(conn, "END");
+ PQclear(res);
+
+ /* close the connection to the database and cleanup */
+ PQfinish(conn);
+
+ return 0;
+}
diff --git a/src/test/libpq/db_list/target.mk b/src/test/libpq/db_list/target.mk
new file mode 100644
index 0000000..97e3311
--- /dev/null
+++ b/src/test/libpq/db_list/target.mk
@@ -0,0 +1,3 @@
+TARGET = test-libpq_list_db
+SRC_CC = main.cc
+LIBS += base stdcxx lwip libc_lwip libc_lwip_nic_dhcp libc_lwip_loopback libpq libc config_args
diff --git a/src/test/libpq/db_update/main.cc b/src/test/libpq/db_update/main.cc
new file mode 100644
index 0000000..9700977
--- /dev/null
+++ b/src/test/libpq/db_update/main.cc
@@ -0,0 +1,77 @@
+/**
+* This example was taken of the article "PostgreSQL C tutorial" on the url next.
+* URL=http://zetcode.com/db/postgresqlc/
+*/
+
+#include
+#include
+#include
+
+void do_exit(PGconn *conn) {
+
+ PQfinish(conn);
+ exit(1);
+}
+
+int main(int argc, char **argv) {
+ const char *conninfo;
+
+ if (argc > 0)
+ conninfo = argv[0];
+ else
+ conninfo = "dbname=postgres";
+
+ PGconn *conn = PQconnectdb(conninfo);
+
+ if (PQstatus(conn) == CONNECTION_BAD) {
+
+ fprintf(stderr, "Connection to database failed: %s\n",
+ PQerrorMessage(conn));
+
+ PQfinish(conn);
+ exit(1);
+ }
+
+ PGresult *res = PQexec(conn, "BEGIN");
+
+ if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+
+ printf("BEGIN command failed\n");
+ PQclear(res);
+ do_exit(conn);
+ }
+
+ PQclear(res);
+
+ res = PQexec(conn, "UPDATE Cars SET Price=23700 WHERE Id=8");
+
+ if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+
+ printf("UPDATE command failed\n");
+ PQclear(res);
+ do_exit(conn);
+ }
+
+ res = PQexec(conn, "INSERT INTO Cars VALUES(9,'Mazda',27770)");
+
+ if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+
+ printf("INSERT command failed\n");
+ PQclear(res);
+ do_exit(conn);
+ }
+
+ res = PQexec(conn, "COMMIT");
+
+ if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+
+ printf("COMMIT command failed\n");
+ PQclear(res);
+ do_exit(conn);
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ return 0;
+}
diff --git a/src/test/libpq/db_update/target.mk b/src/test/libpq/db_update/target.mk
new file mode 100644
index 0000000..42cbbd2
--- /dev/null
+++ b/src/test/libpq/db_update/target.mk
@@ -0,0 +1,3 @@
+TARGET = test-libpq_update
+SRC_CC = main.cc
+LIBS += base stdcxx libc-net lwip libc_lwip libc_lwip_nic_dhcp libc_lwip_loopback libc libpq config_args
diff --git a/src/test/libpqxx/conection_test/main.cc b/src/test/libpqxx/conection_test/main.cc
new file mode 100644
index 0000000..c9085ea
--- /dev/null
+++ b/src/test/libpqxx/conection_test/main.cc
@@ -0,0 +1,40 @@
+/**
+* This example was taken of the article "PostgreSQL - C/C++ Interface" on the url next.
+* URL=http://www.tutorialspoint.com/postgresql/postgresql_c_cpp.htm
+*/
+
+#include
+#include
+
+#include
+
+using namespace std;
+using namespace pqxx;
+
+int main()
+{
+
+ try{
+
+ connection C("dbname=postgres user=postgres password=ok \
+ hostaddr=10.12.119.178 port=5432");
+
+ if (C.is_open()) {
+ cout << "Opened database successfully: " << C.dbname() << endl;
+ } else {
+ cout << "Can't open database" << endl;
+ return 1;
+ }
+ Timer::Connection timer;
+ timer.usleep(100000);
+
+
+ C.disconnect ();
+
+ }catch (const std::exception &e){
+ cerr << e.what() << std::endl;
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/src/test/libpqxx/conection_test/target.mk b/src/test/libpqxx/conection_test/target.mk
new file mode 100644
index 0000000..e726f7a
--- /dev/null
+++ b/src/test/libpqxx/conection_test/target.mk
@@ -0,0 +1,3 @@
+TARGET = test-conection
+SRC_CC = main.cc
+LIBS += base stdcxx libc-net lwip libc_lwip libc_lwip_nic_dhcp libc_lwip_loopback libc libpq libpqxx config_args
diff --git a/src/test/libpqxx/creation_table/main.cc b/src/test/libpqxx/creation_table/main.cc
new file mode 100644
index 0000000..cd19128
--- /dev/null
+++ b/src/test/libpqxx/creation_table/main.cc
@@ -0,0 +1,52 @@
+/**
+* This example was taken of the article "PostgreSQL - C/C++ Interface" on the url next.
+* URL=http://www.tutorialspoint.com/postgresql/postgresql_c_cpp.htm
+*/
+
+#include
+#include
+
+using namespace std;
+using namespace pqxx;
+
+int main(int argc, char* argv[])
+{
+ char * sql;
+
+ try{
+ connection C("dbname=testdb user=postgres password=ok \
+ hostaddr=10.12.119.178 port=5432");
+
+ if (C.is_open()) {
+ cout << "Opened database successfully: " << C.dbname() << endl;
+ } else {
+ cout << "Can't open database" << endl;
+ return 1;
+ }
+
+ /* Create SQL statement */
+ sql = "CREATE TABLE COMPANY(" \
+ "ID INT PRIMARY KEY NOT NULL," \
+ "NAME TEXT NOT NULL," \
+ "AGE INT NOT NULL," \
+ "ADDRESS CHAR(50)," \
+ "SALARY REAL );";
+
+ /* Create a transactional object. */
+ work W(C);
+
+ /* Execute SQL query */
+ W.exec( sql );
+ W.commit();
+ cout << "Table created successfully" << endl;
+
+ C.disconnect ();
+
+ }catch (const std::exception &e){
+ cerr << e.what() << std::endl;
+ return 1;
+ }
+
+ return 0;
+
+}
diff --git a/src/test/libpqxx/creation_table/target.mk b/src/test/libpqxx/creation_table/target.mk
new file mode 100644
index 0000000..1884ccb
--- /dev/null
+++ b/src/test/libpqxx/creation_table/target.mk
@@ -0,0 +1,3 @@
+TARGET = test-creation_table
+SRC_CC = main.cc
+LIBS += base stdcxx libc-net lwip libc_lwip libc_lwip_nic_dhcp libc_lwip_loopback libc libpq libpqxx config_args
diff --git a/src/test/libpqxx/delete_operation/main.cc b/src/test/libpqxx/delete_operation/main.cc
new file mode 100644
index 0000000..a461963
--- /dev/null
+++ b/src/test/libpqxx/delete_operation/main.cc
@@ -0,0 +1,62 @@
+/**
+* This example was taken of the article "PostgreSQL - C/C++ Interface" on the url next.
+* URL=http://www.tutorialspoint.com/postgresql/postgresql_c_cpp.htm
+*/
+
+#include
+#include
+
+using namespace std;
+using namespace pqxx;
+
+int main(int argc, char* argv[])
+{
+ char * sql;
+
+ try{
+ connection C("dbname=testdb user=postgres password=ok \
+ hostaddr=10.12.119.178 port=5432");
+
+ if (C.is_open()) {
+ cout << "Opened database successfully: " << C.dbname() << endl;
+ } else {
+ cout << "Can't open database" << endl;
+ return 1;
+ }
+
+ /* Create a transactional object. */
+ work W(C);
+ /* Create SQL DELETE statement */
+ sql = "DELETE from COMPANY where ID = 2";
+ /* Execute SQL query */
+ W.exec( sql );
+ W.commit();
+ cout << "Records deleted successfully" << endl;
+
+ /* Create SQL SELECT statement */
+ sql = "SELECT * from COMPANY";
+
+ /* Create a non-transactional object. */
+ nontransaction N(C);
+
+ /* Execute SQL query */
+ result R( N.exec( sql ));
+
+ /* List down all the records */
+ for (result::const_iterator c = R.begin(); c != R.end(); ++c) {
+ cout << "ID = " << c[0].as() << endl;
+ cout << "Name = " << c[1].as() << endl;
+ cout << "Age = " << c[2].as() << endl;
+ cout << "Address = " << c[3].as() << endl;
+ cout << "Salary = " << c[4].as() << endl;
+ }
+ cout << "Operation done successfully" << endl;
+ C.disconnect ();
+
+ }catch (const std::exception &e){
+ cerr << e.what() << std::endl;
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/src/test/libpqxx/delete_operation/target.mk b/src/test/libpqxx/delete_operation/target.mk
new file mode 100644
index 0000000..2a355e5
--- /dev/null
+++ b/src/test/libpqxx/delete_operation/target.mk
@@ -0,0 +1,3 @@
+TARGET = test-delete_operation
+SRC_CC = main.cc
+LIBS += base stdcxx libc-net lwip libc_lwip libc_lwip_nic_dhcp libc_lwip_loopback libc libpq libpqxx config_args
diff --git a/src/test/libpqxx/insert_operation/main.cc b/src/test/libpqxx/insert_operation/main.cc
new file mode 100644
index 0000000..164f355
--- /dev/null
+++ b/src/test/libpqxx/insert_operation/main.cc
@@ -0,0 +1,53 @@
+/**
+* This example was taken of the article "PostgreSQL - C/C++ Interface" on the url next.
+* URL=http://www.tutorialspoint.com/postgresql/postgresql_c_cpp.htm
+*/
+
+#include
+#include
+
+using namespace std;
+using namespace pqxx;
+
+int main(int argc, char* argv[])
+{
+ char * sql;
+
+ try{
+ connection C("dbname=testdb user=postgres password=ok \
+ hostaddr=10.12.119.178 port=5432");
+
+ if (C.is_open()) {
+ cout << "Opened database successfully: " << C.dbname() << endl;
+ } else {
+ cout << "Can't open database" << endl;
+ return 1;
+ }
+
+ /* Create SQL statement */
+ sql = "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) " \
+ "VALUES (1, 'Paul', 32, 'California', 20000.00 ); " \
+ "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) " \
+ "VALUES (2, 'Allen', 25, 'Texas', 15000.00 ); " \
+ "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)" \
+ "VALUES (3, 'Teddy', 23, 'Norway', 20000.00 );" \
+ "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)" \
+ "VALUES (4, 'Mark', 25, 'Rich-Mond ', 65000.00 );";
+
+ /* Create a transactional object. */
+ work W(C);
+
+ /* Execute SQL query */
+ W.exec( sql );
+ W.commit();
+ cout << "Records created successfully" << endl;
+
+ C.disconnect ();
+
+ }catch (const std::exception &e){
+ cerr << e.what() << std::endl;
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/src/test/libpqxx/insert_operation/target.mk b/src/test/libpqxx/insert_operation/target.mk
new file mode 100644
index 0000000..05cdd91
--- /dev/null
+++ b/src/test/libpqxx/insert_operation/target.mk
@@ -0,0 +1,3 @@
+TARGET = test-insert_operation
+SRC_CC = main.cc
+LIBS += base stdcxx libc-net lwip libc_lwip libc_lwip_nic_dhcp libc_lwip_loopback libc libpq libpqxx config_args
diff --git a/src/test/libpqxx/select_operation/main.cc b/src/test/libpqxx/select_operation/main.cc
new file mode 100644
index 0000000..229df31
--- /dev/null
+++ b/src/test/libpqxx/select_operation/main.cc
@@ -0,0 +1,55 @@
+/**
+* This example was taken of the article "PostgreSQL - C/C++ Interface" on the url next.
+* URL=http://www.tutorialspoint.com/postgresql/postgresql_c_cpp.htm
+*/
+
+#include
+#include
+
+using namespace std;
+using namespace pqxx;
+
+int main(int argc, char* argv[])
+{
+ char * sql;
+
+ try{
+ connection C("dbname=testdb user=postgres password=ok \
+ hostaddr=10.12.119.178 port=5432");
+
+ if (C.is_open()) {
+ cout << "Opened database successfully: " << C.dbname() << endl;
+ } else {
+ cout << "Can't open database" << endl;
+ return 1;
+ }
+
+ /* Create SQL statement */
+ sql = "SELECT * from COMPANY";
+
+ /* Create a non-transactional object. */
+ nontransaction N(C);
+
+ /* Execute SQL query */
+ result R( N.exec( sql ));
+
+ /* List down all the records */
+ for (result::const_iterator c = R.begin(); c != R.end(); ++c) {
+ cout << "ID = " << c[0].as() << endl;
+ cout << "Name = " << c[1].as() << endl;
+ cout << "Age = " << c[2].as() << endl;
+ cout << "Address = " << c[3].as() << endl;
+ cout << "Salary = " << c[4].as() << endl;
+ }
+
+ cout << "Operation done successfully" << endl;
+
+ C.disconnect ();
+
+ }catch (const std::exception &e){
+ cerr << e.what() << std::endl;
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/src/test/libpqxx/select_operation/target.mk b/src/test/libpqxx/select_operation/target.mk
new file mode 100644
index 0000000..84432d6
--- /dev/null
+++ b/src/test/libpqxx/select_operation/target.mk
@@ -0,0 +1,3 @@
+TARGET = test-select_operation
+SRC_CC = main.cc
+LIBS += base stdcxx libc-net lwip libc_lwip libc_lwip_nic_dhcp libc_lwip_loopback libc libpq libpqxx config_args
diff --git a/src/test/libpqxx/update_operation/main.cc b/src/test/libpqxx/update_operation/main.cc
new file mode 100644
index 0000000..a45a0af
--- /dev/null
+++ b/src/test/libpqxx/update_operation/main.cc
@@ -0,0 +1,61 @@
+/**
+* This example was taken of the article "PostgreSQL - C/C++ Interface" on the url next.
+* URL=http://www.tutorialspoint.com/postgresql/postgresql_c_cpp.htm
+*/
+
+#include
+#include
+
+using namespace std;
+using namespace pqxx;
+
+int main(int argc, char* argv[])
+{
+ char * sql;
+
+ try{
+ connection C("dbname=testdb user=postgres password=ok \
+ hostaddr=10.12.119.178 port=5432");
+ if (C.is_open()) {
+ cout << "Opened database successfully: " << C.dbname() << endl;
+ } else {
+ cout << "Can't open database" << endl;
+ return 1;
+ }
+
+ /* Create a transactional object. */
+ work W(C);
+ /* Create SQL UPDATE statement */
+ sql = "UPDATE COMPANY set SALARY = 25000.00 where ID=1";
+ /* Execute SQL query */
+ W.exec( sql );
+ W.commit();
+ cout << "Records updated successfully" << endl;
+
+ /* Create SQL SELECT statement */
+ sql = "SELECT * from COMPANY";
+
+ /* Create a non-transactional object. */
+ nontransaction N(C);
+
+ /* Execute SQL query */
+ result R( N.exec( sql ));
+
+ /* List down all the records */
+ for (result::const_iterator c = R.begin(); c != R.end(); ++c) {
+ cout << "ID = " << c[0].as() << endl;
+ cout << "Name = " << c[1].as() << endl;
+ cout << "Age = " << c[2].as() << endl;
+ cout << "Address = " << c[3].as() << endl;
+ cout << "Salary = " << c[4].as() << endl;
+ }
+ cout << "Operation done successfully" << endl;
+ C.disconnect ();
+
+ }catch (const std::exception &e){
+ cerr << e.what() << std::endl;
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/src/test/libpqxx/update_operation/target.mk b/src/test/libpqxx/update_operation/target.mk
new file mode 100644
index 0000000..c387488
--- /dev/null
+++ b/src/test/libpqxx/update_operation/target.mk
@@ -0,0 +1,3 @@
+TARGET = test-update_operation
+SRC_CC = main.cc
+LIBS += base stdcxx libc-net lwip libc_lwip libc_lwip_nic_dhcp libc_lwip_loopback libc libpq libpqxx config_args