Refactor project structure: replace User class with ChatUser, integrate Database class, and update CMake configuration for new files
This commit is contained in:
17
db_example.cpp
Normal file
17
db_example.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user