Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "basic_example.h"
- #include <cstdlib>
- #include <fstream>
- #include <iostream>
- #include <memory>
- #include <string>
- #include <ydb-cpp-sdk/client/driver/driver.h>
- #include <ydb-cpp-sdk/client/iam/common/iam.h>
- #include <ydb-cpp-sdk/client/params/params.h>
- #include <ydb-cpp-sdk/client/query/client.h>
- #include <ydb-cpp-sdk/client/query/query.h>
- #include <ydb-cpp-sdk/client/query/tx.h>
- #include <ydb-cpp-sdk/client/types/status/status.h>
- using namespace NYdb;
- using namespace NYdb::NQuery;
- int main(int argc, char** argv) {
- auto driverConfig =
- TDriverConfig()
- .SetEndpoint("grpc://ydb-local:2136")
- .SetDatabase("/local")
- .SetCredentialsProviderFactory(CreateLoginCredentialsProviderFactory({.User = "root", .Password = "1234"}));
- TDriver driver(driverConfig);
- TQueryClient client(driver);
- auto result = client.RetryQuerySync([](TSession session) {
- auto query =
- "CREATE TABLE series(series_id Uint64, title Utf8, series_info Utf8, "
- "release_date Uint64, PRIMARY KEY(series_id));";
- return session.ExecuteQuery(query, TTxControl::NoTx()).GetValueSync();
- });
- const auto status = result.GetStatus();
- driver.Stop(true);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement