libpqxx

Postgresql connectors using VC++

☆樱花仙子☆ 提交于 2021-01-24 11:19:54
问题 How to add Libpqxx library in visual c++ .I googled it from past 2 days not able to get solution for the same I have downloaded and added libpqxx-4.0 but not able to add in visual studio can any give proper solution for this. Thanks in advance 回答1: As it’s my first contribution I will take the time to answer this regardless of the limited information provided by Raveendra konda. Maybe it will be of assistance to someone new to libpqxx. At the time of writing we are on libpqxx 7.0.7. I will

Compiling with CLion and libpqxx

我只是一个虾纸丫 提交于 2020-04-16 06:20:55
问题 I'm trying to test a connection to my postgreSQL database. I've installed libpqxx from here The official C++ client API for PostgreSQL. I'm using the latest version of CLion for my project, GCC 8.1 on Fedora 28 OS. and I'm going to use the C++11 standard. When I try to compile my code I get: /usr/local/include/pqxx/internal/statement_parameters.hxx:213:13: error: ‘experimental’ in namespace ‘std’ does not name a type const std::experimental::optional<Arg> &arg) ^~~~~~~~~~~~ /usr/local/include

postgresql timestamp to std::chrono value

点点圈 提交于 2020-03-25 23:06:34
问题 What is the appropriate way to work with the the postgresql datatype "timestamp without timezone" from c++ (libpqxx)? I haven't been able to find a way to do this yet. I am restricted to the "timestamp without timezone" datatype in the postgresql and the environment is running utc time. I was hoping to find a mapping to a std::chrono::system_clock::time_point member but I can't find a such in libpqxx. //s has a time_point var and r is a pqxx::result, r[0] is sensible s.creationtime = r[0][

Add libpqxx library to cmake

匆匆过客 提交于 2020-01-14 03:05:32
问题 I am working on my c++ simple project, I faced a crucial problem in CMakelists.txt, i cannot linking libpqxx library incorrect way, I spent two days to solve this problem. i am using c++ 2017, cmake version 3.10, OS ubuntu 16.04, clion this my CMakelists.txt cmake_minimum_required(VERSION 3.10) project(myserver) set(CMAKE_CXX_STANDARD 17) find_package(Boost) IF (Boost_FOUND) include_directories(${Boost_INCLUDE_DIR}) endif() link_directories(/usr/local/lib) include_directories(/usr/local

postgresql libpqxx Several queries as one transaction

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-04 02:29:17
问题 Is it possible to execute one transaction contains several queries, for example insert smth in table1 and insert smth in table2? How I can implement this? I use libpqxx to interact the database and expect an answer relating to that. Thank you. 回答1: pqxx::work is a default transaction type. Use multiple exec() method before commit() to run multiple queries in one transaction: using namespace pqxx; ... connection c("dbname=test user=postgres hostaddr=127.0.0.1"); work w(c); w.exec("create table

Inserting NULL/empty string using libpqxx library

落花浮王杯 提交于 2019-12-20 03:10:40
问题 In the following code snippet, the std::string object with name mac is sometimes an empty string (i.e. "") and I want the prepared statement to treat this variable automatically as null. I wonder how this can be achieved in the below code. In my googling attempts, I happened to find that there is a way to set a flag indicating null value but I could not find a concrete example. Could you please provide an example to achieve this? Thnx. try { mConnection->prepare("insertBulkData",

Using libpqxx for to store data in bulk OR how to use COPY statement in libpqxx

梦想与她 提交于 2019-12-14 02:15:20
问题 To insert bulk data/populate a database in PostgreSQL, the fastest way would be to use COPY. Source I have to populate a database. Right now I am getting write speeds as low as 100-200 per second. This involves sending many individual INSERTS through the C++ library libpqxx . The two reasons I suppose are: The data has many repeated records. (I have raw logs, which I parse and send.) Which causes primary key exception. The one-by-one sending of the Insert Statements. The first one is out of

pqxx reuse / reactivate a work transaction

╄→гoц情女王★ 提交于 2019-12-13 12:01:54
问题 I want to use a pqxx::work for multiples queries AND commitments, while the commit function prevent me from using it again. Here is a simple example : pqxx::connection G_connexion("dbname=basetest user=usertest password=1234"); pqxx::work G_work(G_connexion); int main(int argc, char* argv[]) { G_work.exec("insert into test.table1(nom) VALUES('foo');"); G_work.commit();//until here, no problem G_work.exec("insert into test.table1(nom) VALUES('bar');"); //error, transaction already closed G

How to get after executing INSERT into database fetch id of inserted row?

百般思念 提交于 2019-12-12 12:08:37
问题 I am using c++11 and pqxx to access postgresql database and I need id of inserted row and flag if it was successful or not. How to get after executing INSERT into database fetch id of inserted row ? I have tried to find example on net but without success. work txn(*conn); txn.prepared("insert ")(person_name).exec(); txn.commit(); 回答1: work txn(*conn); pqxx::result r = txn.prepared("insert into t (a,b,c) values (1,2,$1) returning id")(person_name).exec(); txn.commit(); int id = r[0][0].as<int>

PGSQL not loaded in PHP 5.3 Windows under IIS

梦想的初衷 提交于 2019-12-11 11:21:18
问题 I know there are other questions about problems with PGSQL not loading, but I haven't found a solution that works for me and directly addresses an IIS setup under Windows (obviously). Using PostgreSQL 8.4. Since I am a complete novice in PHP (only trying to get MantisBT to run) I find this extremely hard to debug/research. I've set the path to both PostgreSQL bin folder and the PHP folders (v5.3 subfolder first and the PHP root after that). I've checked that libpq.dll is present in all three