18 lines
484 B
C++
18 lines
484 B
C++
#include <iostream>
|
|
#include <pqxx/pqxx>
|
|
|
|
int main() {
|
|
try {
|
|
pqxx::connection c{"dbname=your_db user=your_user password=your_pass host=localhost"};
|
|
pqxx::work txn{c};
|
|
pqxx::result r = txn.exec("SELECT version();");
|
|
for (auto row : r) {
|
|
std::cout << row[0].c_str() << std::endl;
|
|
}
|
|
} catch (const std::exception &e) {
|
|
std::cerr << "PostgreSQL error: " << e.what() << std::endl;
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|