1#include <userver/utest/using_namespace_userver.hpp>
3#include <userver/easy.hpp>
5constexpr std::string_view kSchema = R"~(
6CREATE TABLE IF NOT EXISTS key_value_table (
7 key VARCHAR PRIMARY KEY,
8 value VARCHAR
9)
10)~";
12int main(
int argc,
char* argv[]) {
13 easy::HttpWith<easy::PgDep>(argc, argv)
17 [](
const server::http::HttpRequest& req,
const easy::PgDep& dep) {
18 auto res = dep.pg().Execute(
19 storages::postgres::ClusterHostType::kSlave,
20 "SELECT value FROM key_value_table WHERE key=$1",
23 return res[0][0].As<std::string>();
28 [](
const server::http::HttpRequest& req,
const auto& dep) {
30 storages::postgres::ClusterHostType::kMaster,
31 "INSERT INTO key_value_table(key, value) VALUES($1, $2) ON CONFLICT (key) DO UPDATE SET value = $2",
38 .DefaultContentType(http::content_type::kTextPlain);