
{"id":15904,"date":"2014-07-18T19:43:42","date_gmt":"2014-07-18T19:43:42","guid":{"rendered":"http:\/\/www.beautifulwork.org\/?p=15904"},"modified":"2014-07-18T19:43:42","modified_gmt":"2014-07-18T19:43:42","slug":"how-to-write-a-program-to-find-the-version-of-a-postgresql-server-program-may-not-be-perfect","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2014\/07\/18\/how-to-write-a-program-to-find-the-version-of-a-postgresql-server-program-may-not-be-perfect\/","title":{"rendered":"How to write a program to connect to  a PostgreSQL server ? (program may not be perfect )"},"content":{"rendered":"<pre>\n#include &lt;stdio.h&gt;\n#include &lt;stdlib.h&gt;\n#include &lt;postgresql\/libpq-fe.h&gt;\n\nint main(int argc, char **argv)\n{\nconst char *conninfo;\nconst char *serverversion;\nPGconn *conn;\nconst char *paramtext = \"server_version\";\nconninfo = \"hostaddr = 127.0.0.1 dbname = test user = earl password = bigshot\";\n\nconn = PQconnectdb(conninfo);\nif ( PQstatus(conn) != CONNECTION_OK )\n{\n\nprintf(\"Unable to establish connection: %s\",PQerrorMessage(conn));\nreturn 1;\n}\nelse\n{\nprintf(\"Connection established!\\n\");\nserverversion = PQparameterStatus(conn,paramtext);\nprintf(\"Server Version: %s\\n\",serverversion);\n}\nPQfinish(conn);\nreturn 0;\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;postgresql\/libpq-fe.h&gt; int main(int argc, char **argv) { const char *conninfo; const char *serverversion; PGconn *conn; const char *paramtext = &#8220;server_version&#8221;; conninfo = &#8220;hostaddr = 127.0.0.1 dbname = test user = earl password = bigshot&#8221;; conn = PQconnectdb(conninfo); if ( PQstatus(conn) != CONNECTION_OK ) { printf(&#8220;Unable to establish connection: %s&#8221;,PQerrorMessage(conn)); return &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2014\/07\/18\/how-to-write-a-program-to-find-the-version-of-a-postgresql-server-program-may-not-be-perfect\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to write a program to connect to  a PostgreSQL server ? (program may not be perfect )&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[141,27,91],"tags":[],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/15904"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=15904"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/15904\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=15904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=15904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=15904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}