blob: 73f9e5554bbbf17ef76bdd6f4670743b80c4287f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
/* Copyright (c) 2007, Mark Wong */
#include "display.h"
#include "pg.h"
PGconn *connect_to_db(char *conninfo)
{
PGconn *pgconn = NULL;
pgconn = PQconnectdb(conninfo);
if (PQstatus(pgconn) != CONNECTION_OK) {
/* FIXME: Figure out how to properly display this. */
new_message(MT_standout, " Could not connect to PostgreSQL...");
putchar('\r');
fflush(stdout);
PQfinish(pgconn);
return NULL;
}
return pgconn;
}
|