libpq

Can't create dbConnect to Postgres with SSL

99封情书 提交于 2019-12-19 09:04:26
问题 I'm running a Postgres-9.4 server that I would like to require SSL for. When I connect to the Postgres server from my laptop with either pgadmin or windows odbc connection, it works with SSL. However when I try to connect with R using SSL it fails. library(RPostgreSQL) drv <- dbDriver("PostgreSQL") con <- dbConnect(drv, user = "postgres", password = mypasswd, dbname = "dbname=postgres sslmode=prefer", host = "192.168.1.179") If I set my pg_hba.conf to allow non-ssl connections then this will

Inserting integer array with postgresql in C (libpq)

六月ゝ 毕业季﹏ 提交于 2019-12-14 04:19:19
问题 I'm trying to post an integer array into my postgresql database. I'm aware that I could format everything as a string and then send that string as one SQL command. However, I believe the PQexecParams function should also bring some help. However, I'm kind of lost as how to use it. //we need to convert the number into network byte order int val1 = 131; int val2 = 2342; int val3[5] = { 0, 7, 15, 31, 63 }; //set the values to use const char *values[3] = { (char *) &val1, (char *) &val2, (char *)

FindPostgreSQL.cmake won't work on ubuntu

核能气质少年 提交于 2019-12-12 07:48:04
问题 Ubuntu 12.04 CMake 2.8.9 Postgresql 9.2.2 I'm trying to get the FindPostgreSQL module to find /usr/include/postgresql/libpq-fe.h . Here's what I have in my CMakeLists.txt : find_package(PostgreSQL REQUIRED) This is the error I get: CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:97 (MESSAGE): Could NOT find PostgreSQL (missing: PostgreSQL_TYPE_INCLUDE_DIR) (found version "9.2.2") Call Stack (most recent call first): /usr/share/cmake-2.8/Modules

How to insert text array in PostgreSQL table in binary format using libpq?

社会主义新天地 提交于 2019-12-11 16:21:03
问题 I didn't find any documentation describing how to work with binary arrays in PostgreSQL using libpq. So you have table: CREATE TABLE IF NOT EXISTS test_array ( array_column text[] ) You want to insert array in binary format using PQexecParams How exactly one does this? 回答1: Everything described bellow is tested on PostgreSQL 9.5. PQexecParams has the following prototype: PGresult *PQexecParams(PGconn *conn, const char *command, int nParams, const Oid *paramTypes, const char * const

How to download, compile & install ONLY the libpq source on a server that DOES NOT have PostgreSQL installed

半城伤御伤魂 提交于 2019-12-11 09:27:24
问题 How can I download, compile, make & install ONLY the libpq source on a server (Ubuntu) that DOES NOT have PostgreSQL installed? I have found the libpq source here. However it does NOT seem to be separable from the entire PostgreSQL. Thanks in advance. I DO NOT want to install the entire PostgreSQL. I want to use libpq as a C interface to PostgreSQL on a DIFFERENT server (also Ubuntu) that DOES have it installed. I also found this old link which indicates that the above is POSSIBLE but not HOW

Why is programming interface to database called driver?

不问归期 提交于 2019-12-11 06:46:16
问题 When writing an application which updates or queries a database, we use something called a database driver (e.g. a JDBC driver). I wonder why it is called a driver instead of a library? Is libpq a driver too? 回答1: To quote the Wikipedia article you linked to: In computing, a device driver is a computer program that operates or controls a particular type of device that is attached to a computer. The analogy here is that a database is an external device that the client computer "controls", by

Passing C variables into SQL command

只谈情不闲聊 提交于 2019-12-11 03:46:03
问题 I am a newbie in using libpq and work on a postgresql database. So, far I can insert/update/etc a postgresql database using C program, provided I give the actual values inside the quotes. I want to know how to pass a string/integer variable in the command?? E.g. The following code adds a column called "comment" containing "TRUE" default value into an existing table "people". I need to update the value of the "comment" by "FALSE" where the id=2. #include <stdio.h> #include <stdlib.h> #include

C libpq: get float value from numeric

半腔热情 提交于 2019-12-11 03:43:02
问题 I have a table with float value represented using numeric type. How can I get float value from this field using libpq lib? There is a specialized format for float type in postgres, but I have to work with existing database with numeric fields. I haven't found information about it in the Postgres documentation so every info is appreciated. 回答1: Strictly you can't get an accurate float representation of a numeric . Not for any arbitrary numeric anyway. numeric is arbitrary-precision decimal

python connect to postgresql with libpq-pgpass

馋奶兔 提交于 2019-12-09 17:17:33
问题 I read there is a more secure way to connect to postgresql db without specifying password in source code using http://www.postgresql.org/docs/9.2/static/libpq-pgpass.html . But unfortunatelly I was not able to find any examples of how to import it to my python program and how made my postgresql server to use this file. Please help. 回答1: You don't import it into your Python program. The point of .pgpass is that it is a regular file subject to the system's file permissions, and the libpq driver

Why does `libpq` use polling rather than notification for data fetch?

南楼画角 提交于 2019-12-08 19:25:33
问题 I am reading libpq reference. It has both of sync and async methods. Bu I discovered something strange. When I see PQsendQuery function, it seems to send a query and return immediately. And I expected a callback function to get notified, but there was no such thing and the manual says to poll for data availability. I don't understand why async method is written in polling way. Anyway, as libp is the official client implementation, I believe there should be a good reason for this design. What