Advertisement
popov-aa

Untitled

Nov 3rd, 2024
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | None | 0 0
  1. #include "basic_example.h"
  2.  
  3. #include <cstdlib>
  4. #include <fstream>
  5. #include <iostream>
  6. #include <memory>
  7. #include <string>
  8.  
  9. #include <ydb-cpp-sdk/client/driver/driver.h>
  10. #include <ydb-cpp-sdk/client/iam/common/iam.h>
  11. #include <ydb-cpp-sdk/client/params/params.h>
  12. #include <ydb-cpp-sdk/client/query/client.h>
  13. #include <ydb-cpp-sdk/client/query/query.h>
  14. #include <ydb-cpp-sdk/client/query/tx.h>
  15. #include <ydb-cpp-sdk/client/types/status/status.h>
  16.  
  17. using namespace NYdb;
  18. using namespace NYdb::NQuery;
  19.  
  20. int main(int argc, char** argv) {
  21.   auto driverConfig =
  22.       TDriverConfig()
  23.           .SetEndpoint("grpc://ydb-local:2136")
  24.           .SetDatabase("/local")
  25.           .SetCredentialsProviderFactory(CreateLoginCredentialsProviderFactory({.User = "root", .Password = "1234"}));
  26.  
  27.   TDriver driver(driverConfig);
  28.   TQueryClient client(driver);
  29.  
  30.   auto result = client.RetryQuerySync([](TSession session) {
  31.     auto query =
  32.         "CREATE TABLE series(series_id Uint64, title Utf8, series_info Utf8, "
  33.         "release_date Uint64, PRIMARY KEY(series_id));";
  34.     return session.ExecuteQuery(query, TTxControl::NoTx()).GetValueSync();
  35.   });
  36.  
  37.   const auto status = result.GetStatus();
  38.  
  39.   driver.Stop(true);
  40.   return 0;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement