libpqxx查询postgresql数据库表的通用方法

libpqxx查询postgresql数据库表的通用方法,第1张

概述//   g++ testpqxx.cpp -o testpqxx `pkg-config --libs --cflags libpqxx libpq`//   g++ testpqxx.cpp -o testpqxx -I /opt/PostgreSQL/9.4/include/ -L/opt/PostgreSQL/9.4/lib -lpqxx -lpq#include <iostream
//g++testpqxx.cpp-otestpqxx`pkg-config--libs--cflagslibpqxxlibpq`//g++testpqxx.cpp-otestpqxx-I/Opt/Postgresql/9.4/include/-L/opt/Postgresql/9.4/lib-lpqxx-lpq#include<iostream>#include<pqxx/pqxx>usingnamespacepqxx;usingnamespacestd;intmain(){try{connectionconn("dbname=yout-dbuser=your-usrpassword=your-passwd\					hostaddr=127.0.0.1port=5432");conn.set_clIEnt_enCoding("UTF8");	workw(conn);resultr=w.exec("SELECT*FROMyour-table");for(result::const_iteratorrow=r.begin();row!=r.end();++row){for(tuple::const_iteratorcol=row->begin();col!=row->end();++col)cout<<col->c_str()<<'\t';cout<<endl;}}catch(exception&e){cerr<<e.what()<<endl;return1;}return0;}
总结

以上是内存溢出为你收集整理的libpqxx查询postgresql数据库表的通用方法全部内容,希望文章能够帮你解决libpqxx查询postgresql数据库表的通用方法所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/1174517.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存