Questions tagged [libpq]

libpq is the C application programmer's interface to PostgreSQL. libpq is a set of library functions that allow client programs to pass queries to the PostgreSQL backend server and to receive the results of these queries.

libpq is also the underlying engine for several other PostgreSQL application interfaces, including those written for C++, Perl, Python, Tcl and ECPG. So some aspects of libpq's behavior will be important to you if you use one of those packages.

Client programs that use libpq must include the header file libpq-fe.h and must link with the libpq library.

345 questions
0
votes
1 answer

Error about sending an image into bytea column in postgresql db with libpq library

I'm coding in C and using Libpq library of Postgresql and I would like to store a PNG image into the database in "bytea" type. I have been searching on the net for hours and couldn't find a good example to handle this work, so wanted to write here…
Horizon1710
  • 792
  • 10
  • 28
0
votes
1 answer

Preparing, Storing, Retrieving Encrypted Data in PostgreSQL

Does anyone know how to properly prepare for BYTEA data type insertion into postgresql? I have an encrypted string generated from libmcrypt. I am I wish to store the encryption in a table column defined as "cdata bytea not null" I have the…
Rico
  • 11
  • 6
0
votes
1 answer

store function output in an array

I have the follwoing function which works fine, BUT I am not sure if it is storing anything in the array. DECLARE _r record; point character varying[] := '{}'; i int := 0; BEGIN FOR _r IN EXECUTE ' SELECT a.'||…
IT_info
  • 707
  • 4
  • 16
  • 36
0
votes
1 answer

PostgreSQL's libpq and SELECT FROM

I have code like below (it's partial, ofcourse). I can connect sucessfully to the database, I can do INSERT INTO and all that stuff, but the result of SELECT FROM never can be displayed. snprintf(sqlSelect, sizeof(sqlSelect), "select * from %s",…
Teddy
  • 217
  • 1
  • 3
  • 6
0
votes
2 answers

How to close initialized connections when program is terminated by user

Im writing a daemon in C that posts data to PostgreSQL database using libpq library. It has structure like this: init(...) // init function, opens connection while(1){export(...)} // sends commands When someone kills the application, it leaves open…
Tomáš Šíma
  • 834
  • 7
  • 26
0
votes
2 answers

Getting size of field in libpq-fe

I am using the libpq-fe library in C to contact to a postgres database. I am calling a stored procedure from my code using libpqfe which returns a timestamp. I want to store this timestamp to a char array. But to do so I first have to know the size…
Abhishek Gupta
  • 6,465
  • 10
  • 50
  • 82
0
votes
2 answers

libpq - writing tests

I'm writing a C++ wrapper for libpq. However I can't figure out how I should write my unit tests. My initial reaction was to just wrap the libpq interface into something that's mockable, but that kind of defeats the purpose. Has anyone done this…
Ilia Choly
  • 18,070
  • 14
  • 92
  • 160
0
votes
1 answer

libpq send integer as binary

I have a libpq program that is routinely inserting numbers into a database. These numbers, which I'm expecting to grow quite large, are stored int the uint64_t type. I'm wanting to send the integer to libpq as binary, but Postgres won't be able to…
Edward
  • 1,786
  • 1
  • 15
  • 33
0
votes
1 answer

Unable to install psycopg2 because of dependancy errors in libpq-dev

I have been trying to install psycopg2 for use in a virtualenv. I managed to find that it depended on libpq-dev (because pip give me a Error: pg_config executable not found. error) which could be install using apt-get install libpq-dev. However all…
thomas
  • 949
  • 6
  • 20
-1
votes
1 answer

`defer` order when variable persists

I've seen a few questions on Go's defer, but nothing like the implementation I'm trying to do yet. The test case The application I'm writing does a fair bit of db transactions, so I have a function func getCursor() *sql.Tx { psqlInfo :=…
robotHamster
  • 609
  • 1
  • 7
  • 24
-1
votes
1 answer

Kali 1.1.0 - issue with bundle install

When trying to run pattern_create.rb I get an error message that rake-10.4.2 is missing and I need to run bundle install. Running bundle install it run's until Installing pg (0.18.1) with native extensions results in an error: …
GSOlion
  • 43
  • 4
-2
votes
1 answer

How to get auto increment value in prepared command in postgresql?

I create table with this sql command: create table recorddata ( id serial, name char(20), age int); just like auto increment in mysql, I want id is auto increment in postgresql. then, insert data in a transaction.sql command: begin,…
shalow
  • 64
  • 1
  • 4
-2
votes
1 answer

CodeBlock undefined reference to PQconnectdb

i created a new project and copy libpq.lib and header in specific directory of my project. I also add linker destination but when i build i get an undefined reference. So i forgot something but what ?
sviardot
  • 17
  • 1
-2
votes
1 answer

Updating PostgreSQL table with binary data

I have a std::stringstream strs variable with this serialized binary data: �G�{SSF��>%�����hgRQ;Tjh A "ʐk�R3 1[Z�yA _�Kx O��� ���f��' ����t %��+>, ���~� 삾�+/ Tb�Ҷ�7 �(���� �Q1�5m& ��( G#�bm 3O�AN ) �DP߇g �0=ʆ�0 ���j�u E�3�� �G�#�"…
TalG
  • 677
  • 1
  • 9
  • 26
-3
votes
1 answer

How can I bind a NULL value to a prepared statements with libpq library and C++?

I have to use libpq library NOT libpqxx and I couldn't find out how to bind NULL value for numeric type at a prepared statement. I tried NULL or null or even with "" but it didn't work. ... std::string statements = "insert into…
Tomtom
  • 45
  • 7
1 2 3
22
23