added session to work.cpp

This commit is contained in:
Sascha Kühl 2025-07-08 14:15:45 +02:00
parent d4253ee4d0
commit 7fd11ad174
2 changed files with 9 additions and 2 deletions

View File

@ -19,5 +19,7 @@ target_link_libraries(work PRIVATE
matador-core matador-core
matador-orm matador-orm
${CMAKE_DL_LIBS} ${CMAKE_DL_LIBS}
${SQLite3_LIBRARIES} ${PostgreSQL_LIBRARY}
) )
add_dependencies(work matador-postgres)

View File

@ -89,11 +89,16 @@ int main() {
.and_then([&schema] { return schema.attach<jobs::IdListPayload, jobs::Payload>("id_payloads"); }) .and_then([&schema] { return schema.attach<jobs::IdListPayload, jobs::Payload>("id_payloads"); })
.and_then([&schema] { return schema.attach<jobs::Task>("tasks"); }); .and_then([&schema] { return schema.attach<jobs::Task>("tasks"); });
if (!result.is_ok()) { if (!result) {
std::cout << "error: " << result.err().message() << std::endl; std::cout << "error: " << result.err().message() << std::endl;
return 0; return 0;
} }
sql::connection_pool<sql::connection> pool("postgres://test:test123!@127.0.0.1:15432/postgres", 4);
orm::session ses(pool);
result = ses.create_schema();
schema.dump(std::cout); schema.dump(std::cout);
// const std::string dns{"sqlite://demo.db"}; // const std::string dns{"sqlite://demo.db"};
// sql::connection c(dns); // sql::connection c(dns);