Created
October 29, 2015 09:49
-
-
Save harwinder/7e74e4cbdec4eb892c1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define SOCI_USE_BOOST | |
#include <boost-tuple.h> | |
#include <soci.h> | |
#include <postgresql/soci-postgresql.h> | |
using namespace soci; | |
/* | |
CREATE TABLE test_soci | |
( | |
col_int int, | |
col_str varchar(100) | |
); | |
*/ | |
int main() | |
{ | |
typedef boost::tuple<int, std::string> row_test_soci; | |
session sql(postgresql, | |
"host=10.0.0.30 user=test password=test dbname=test"); | |
rowset< row_test_soci > rs = ( | |
sql.prepare << "SELECT col_int, col_str FROM TEST_SOCI" | |
); | |
for(rowset< row_test_soci >::const_iterator it = rs.begin(); | |
it != rs.end(); | |
++it) | |
{ | |
std::cout << "col_int: " << it->get<0>() << ", " | |
<< "col_str: " << it->get<1>() << std::endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment