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
1
vote
1 answer

How to create a type '[*c]const [*c]const u8' for paramValues of PQexecParams

I'm trying to use the libpq library in zig. I'm trying to pass paramValues to PQexecParams. I'm just not sure how to create the required type. The type required by the documentation is: const char * const *paramValues So something like: const char…
pooya72
  • 1,003
  • 9
  • 15
1
vote
1 answer

PostgreSQL Save and Pick files as large objects with C libpq

I am working in this issue since 2 weeks without any result. Do someone know how to manage with lipq with blobs or bytea without losing format and any data? The exported file size is 0B, I can not understand the steps I must follow to upload a file…
Kornelius
  • 33
  • 5
1
vote
1 answer

PQconnectdb set search_path (schema) while connecting

How do I specify the search_path while connecting to my postgres db using PQconnectdb? I want to set the search_path to my_schema. I'm currently using the following connection command: PQconnectdb("host=localhost user=my_user password=my_password…
m7913d
  • 10,244
  • 7
  • 28
  • 56
1
vote
0 answers

How to install PHP using asdf

I am trying to install PHP using asdf on Ubuntu 20.04 LTS without success. While installing, it generates many errors regarding missing packages in the main installation like the absence of re2c, bison, libcurl, etc... I succeeded in install all…
Sapiosonic
  • 11
  • 3
1
vote
0 answers

How do i fix PDOException::("SQLSTATE[08006] [7] SCRAM authentication requires libpq version 10 or above")

i get an error when I'm trying to connect to postgresql server from a Symfony application. I have everything set up but can't seem to figure out how to upgrade libpq version. I'm using postgresql 13.1
1
vote
1 answer

`sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) SSL SYSCALL error: EOF detected` on Ubuntu but not on Mac OS

I am writing a simple web-scraper in python3.7 using asyncio and multiprocessing. The general architecture looks as follows: for i in range(self.number_processes - len(processes)): p = Process(target=AsyncProcessWrapper().run_main_loop) …
DaveTheAl
  • 1,995
  • 4
  • 35
  • 65
1
vote
2 answers

Can I get original Query from PGresult* object in Postgres?

mConn = PQconnectdb( conninfo ); const char* pQuery = "SELECT X FROM Y..."; PGresult* stmt = PQexec( mConn, pQuery ); can I do this? char * original_query = Take( stmt ); thx
Mike
  • 1,008
  • 3
  • 12
  • 15
1
vote
2 answers

Does libpq support something equivalent of Oracle's array binds?

Oracle has something they call array binds (from docs) where the SQL sent could be UPDATE mytable SET val = :2 WHERE id = :1 along with an array bind with contents: 1 | val1 2 | val2 3 | val3 (PS. The array's size is > 1000 items, the 3 items are…
meastp
  • 682
  • 1
  • 7
  • 15
1
vote
1 answer

How to generate an AuthenticationMD5Password message

I'm creating a postgresql client in gdscript (you can answer my question even if you don't know how to code in gdscript). To do this I use the postgresql protocol specification I managed to contact the server and it asks me for…
1
vote
0 answers

::LoadLibraryW fails with ERROR_PROCESS_MODE_NOT_BACKGROUND

I have built postgres windows libpq.dll following the documentation https://www.postgresql.org/docs/9.6/install-windows-full.html. I was able to build libpq.dll but when I am using the dll in my code it fails. Below is the sample code moduleHandle =…
Meraj Hussain
  • 329
  • 1
  • 6
  • 24
1
vote
0 answers

Can not connect to postgresql in libpq

I can't connect to database using this code: void connect_to_db(){ connection = PQconnectdb("user=username password=123 dbname=project_db"); printf("%s\n", PQerrorMessage(connection)); } int main() { connect_to_db(); …
Amir reza Riahi
  • 1,540
  • 2
  • 8
  • 34
1
vote
1 answer

can not check whether a table exists or not in postgresql

I'm writing a C program that connects to a postgreql db.I'm trying to check for a table : PGresult *re=PQexec(connection, "SELECT to_regclass('fp_stores_data')"); this variable is a global variable. but when I compile the code this error…
Amir reza Riahi
  • 1,540
  • 2
  • 8
  • 34
1
vote
1 answer

Checking if a range contains a value broken in PQexecPrepared (works in psql)

I have this (rather ugly, generated) prepared statement to fetch some game data. I try to check if a value ($3) is contained in spawn_level_range (which is an int4range) by doing $3<@quests.spawn_level_range: SELECT quests.id, …
user3818491
  • 498
  • 1
  • 6
  • 16
1
vote
1 answer

PostgresSQL - SQL Prepared Statement vs String Escaping preventing SQL injection attacks

Hi I'm writing an c++ application using libpqxx to insert rows into a Postgres SQL Table and the data being written is user inputted so I need to guard against SQL injection attacks. From what I see online I can take two approaches: Prepared…
Steven
  • 307
  • 2
  • 13
1
vote
2 answers

libpq-fe.h and c program closing

I've got a problem with a C program that connects with localhost database on postgresql. Code looks similar to this: #include #include int main() { int dane; PGconn *dbh; // definujemy uchwyt do bazy – jest to specjalna…
Kamil
  • 782
  • 1
  • 6
  • 22