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

Prepare multi rows with libpq

How can I insert about 100 rows in a row with libpq using PQprepare? I don't know, maybe my parameters are false... Thank you for reply. const char command[] = "INSERT INTO car (id, name, price, day, time)" "VALUES($1, $2,…
Derrick
  • 21
  • 3
0
votes
1 answer

How use PQexecParams in libpq?

I've read the document but still I'm confused how use this function to send this command to server: INSERT INTO table_1($1,$2,$3); this function I wrote: void add_data_to_db(char table){ const char data[2][2] = {"12","me"}; re =…
Amir reza Riahi
  • 1,540
  • 2
  • 8
  • 34
0
votes
1 answer

can not create a table in database with libpq in C

I created a c function that create a table on my postgresql db. here: #include #include #include PGconn *connection; PGresult *re; void create_table(){ re= PQexec(connection, "SELECT…
Amir reza Riahi
  • 1,540
  • 2
  • 8
  • 34
0
votes
1 answer

Undefined symbol dlsyn when installing posgresql

I am trying to install postresql on a docker container based on buster. It used to work, now devops changed the base image and s*** hit the fan. So I am running apt install postgresql postgresql-contrib and on setup I get the following error: o …
David
  • 182
  • 1
  • 1
  • 8
0
votes
1 answer

PostgreSQL definition of service not found (pgAdmin, psql, ...)

Context I have a simple pg_service.conf file located at ${HOME}/pg_service.conf which content is as follow: # comment [service_name] host=localhost port=5432 dbname=databasename user=username Issue Whenever I try to create a new server from pgAdmin…
swiss_knight
  • 5,787
  • 8
  • 50
  • 92
0
votes
1 answer

pgbouncer - could not connect to server: Address already in use (0x00002740/10048)

I have an app using libpq to connect to postgresql server and using pgbouncer as connection pool if (pconn == nullptr) { pconn = PQconnectdb(chrConnectStr); } if (PQstatus(pconn) == CONNECTION_BAD) { //If it fails, try…
Ryo
  • 995
  • 2
  • 25
  • 41
0
votes
0 answers

Error connecting to a PostgreSQL Azure database using libpq

I am trying to connect to a PostgreSQL Azure database using libpq on Windows 10. The syntax is as below -- PQinitSSL(1); PGconn* pConn = PQconnectdb("host=nameofhost.postgres.database.azure.com port=5432 dbname={your_database}…
HongY
  • 1
0
votes
1 answer

In a PostgreSQL/Rails app, what decides how the 'id' field is allocated when 'create' method is called?

I have a model called "Post". Because of reasons, I had to create Posts with specific id values. When I run Post.last, it gives me the Post with the highest id value. However, when I run Post.create(), it tries to create a Post with an id greater…
Joe Morano
  • 1,715
  • 10
  • 50
  • 114
0
votes
1 answer

db.QueryRow() returning the wrong number of arguments

I have a file called user.go, the function GetUserByUsernameOrEmail returns the user model and an error. It grabs this user information from the database. My goal is to get all parameters I SELECT of the user, but it returns one fewer than it…
0
votes
2 answers

psycopg2: statement return codes

I have a Postgres query which I execute in Python like so cursor.execute('INSERT INTO my_data(id, val, bonus) VALUES (1, 2, 3) ON CONFLICT (id) DO UPDATE SET val = ex.val;') I'd like to be able to tell if a fresh insert is happening to decide some…
Madden
  • 1,024
  • 1
  • 9
  • 27
0
votes
1 answer

PostgreSQL says 'symbol not found' when I try to use PQnfelds

I wrote a C function to be executed from within PostgreSQL (with a CREATE FUNCTION ... LANGUAGE C; command) but when I do so, it responds 'PQnfields: symbol not found'. I tried to include the path to where the libpq library is when I compile, like…
Gaëtan
  • 779
  • 1
  • 8
  • 26
0
votes
0 answers

PostgreSQL: libpq functionality directly through the backend?

libpq is the C application programmer's interface to PostgreSQL. As I understand, this establishes multiple low-level connections to PostgreSQL's backend. I was wondering, as a PostgreSQL backend developer, for example, a PostgreSQL extension…
Zeruno
  • 1,391
  • 2
  • 20
  • 39
0
votes
1 answer

Is PQntuples guaranteed to be 1 with PQsetSingleRowMode?

I've started using PQsetSingleRowMode to be able to have more control over the data as it is streaming after PQsendQueryParams. You need to call PQgetResult a lot more, but is it as a matter of fact guaranteed that you'll get a single record each…
Stijn Sanders
  • 35,982
  • 11
  • 45
  • 67
0
votes
1 answer

How to insert array of bytes in PostgreSQL table via libpq C++ API

I am trying to update table CREATE TABLE some_table ( id integer NOT NULL, client_fid bigint NOT NULL, index bytea[], update_time timestamp without time zone ) WITH ( OIDS = FALSE using modified code snipped from here How to…
0
votes
1 answer

How can I insert multi-entry array using [libpg] "COPY FROM STDIN" method in PostgreSQL?

I am using libpq to insert bulk data from a C program. The bulk data contain data type that is double array, which in PostgreSQL is float8[]. My platform is Windows 10, PostgreSQL 11. The tested table is structured as follows: create table…
Shore
  • 827
  • 9
  • 24