Re: accessing postgres from c++ - Mailing list pgsql-general

From Laurenz Albe
Subject Re: accessing postgres from c++
Date
Msg-id d5161927b0fd2abf1f8981c691acae706c26f3a0.camel@cybertec.at
Whole thread Raw
In response to accessing postgres from c++  (Rino Mardo <rino19ny@gmail.com>)
Responses Re: accessing postgres from c++
List pgsql-general
On Tue, 2022-06-21 at 10:56 +0800, Rino Mardo wrote:
> hi. i found odbc.postgresql.org when i was looking for a way to hook up my c++ project to postgresql server.
> installed it and tested to be successful in connection. this was when i had postgresql
> running from a virtualbox vm in Ubuntu. 
> 
> i installed a postgresql container using Docker for Windows in my laptop. from a Windows terminal i can
> connect to the postgresql container and from there use psql client to create database.
> 
> when postgresql was running in an Ubuntu vm in virtualbox, i wasn't able to test the c++ connection.
> now i want to but can't find a way how. either from python or any programming language.
> 
> i guess my problem is more of the programming than db server side but i thought to try asking here
> in case someone can help. thanks.

I am surprised that you choose to be fettered by the constraints of a generic API like ODBC.
For me, that only makes sense if you want to be portable to different databases.

I would use the powerful C API of libpq, or, if you want some C++ boilerplate around it,
use libpqxx.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com



pgsql-general by date:

Previous
From: Aditya Bhardwaj
Date:
Subject: How to use 32 bit ODBC driver
Next
From: Dominique Devienne
Date:
Subject: Re: accessing postgres from c++