main(int argc, char **argv) { int ret; pq_session session; ret = pq_init(&session); if(ret) printf("pq_init failed.\n"); char conn_str[] = "host=localhost dbname=pagila"; ret = pq_connect(&session, conn_str, strlen(conn_str)); if(ret) printf("pq_connect failed.\n"); pq_check_connection(&session); ret = pq_execute(&session, "select current_date;"); if(ret) printf("pq_execute failed.\n"); ret = pq_fetch(&session); if(ret) printf("pq_finish failed.\n"); pq_finish(&session); pq_end(&session); }
static PyObject * psyco_repl_curs_start_replication_expert(replicationCursorObject *self, PyObject *args, PyObject *kwargs) { cursorObject *curs = &self->cur; connectionObject *conn = self->cur.conn; PyObject *res = NULL; char *command; long int decode = 0; static char *kwlist[] = {"command", "decode", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|l", kwlist, &command, &decode)) { return NULL; } EXC_IF_CURS_CLOSED(curs); EXC_IF_GREEN(start_replication_expert); EXC_IF_TPC_PREPARED(conn, start_replication_expert); Dprintf("psyco_repl_curs_start_replication_expert: '%s'; decode: %ld", command, decode); if (pq_execute(curs, command, conn->async, 1 /* no_result */, 1 /* no_begin */) >= 0) { res = Py_None; Py_INCREF(res); self->decode = decode; gettimeofday(&self->last_io, NULL); } return res; }