testPQ

/*
 ============================================================================
 Name        : testPQ.c
 Author      : chuck
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

/*
gcc xmSkeleton.c -o xmSkeleton -I/usr/local/include -I/usr/X11R6/include -L/usr/src/lib -L/usr/local/lib -L/usr/X11R6/lib -lXm -lXt -lX11 -lXpm
*/

#include 
#include 

#include 

int main(void) {

	PGconn *dbConn;
	char *dbIP;
	const char *connInfo;

	//dbIP = "192.168.1.120";
	dbIP = "127.0.0.1";

	/* connect to cnog db */
	asprintf(&connInfo,
		"hostaddr=%s port=%s dbname=%s user=%s\n",
			dbIP, "5432", "init_main", "postgres");
	printf("connInfo = %s\n", connInfo);
	dbConn = PQconnectdb(connInfo);

	/* Check to see that the backend connection was successfully made */
	if(PQstatus(dbConn) != CONNECTION_OK) {
		fprintf(stderr, "Connection to database failed: %s", PQerrorMessage(dbConn));
		return EXIT_SUCCESS;
	}

	return EXIT_SUCCESS;
}