diff options
author | bazeltsev <bazeltsev@ydb.tech> | 2022-11-02 21:43:19 +0300 |
---|---|---|
committer | bazeltsev <bazeltsev@ydb.tech> | 2022-11-02 21:43:19 +0300 |
commit | 0b74f5913a3605197aea520fb0663f00172a8ddb (patch) | |
tree | 3f25bb4a2711d4db6eb7db31337f72f1dfe07e61 | |
parent | 0ca12a0548e3af769774fd7fca945e36bde401e9 (diff) | |
download | ydb-0b74f5913a3605197aea520fb0663f00172a8ddb.tar.gz |
Added international includes
updated
5 files changed, 86 insertions, 145 deletions
diff --git a/ydb/docs/_includes/go/auth-static-database-sql.md b/ydb/docs/_includes/go/auth-static-database-sql.md new file mode 100644 index 0000000000..9f3173dcbc --- /dev/null +++ b/ydb/docs/_includes/go/auth-static-database-sql.md @@ -0,0 +1,18 @@ +```go +package main + +import ( + "context" + + _ "github.com/ydb-platform/ydb-go-sdk/v3" +) + +func main() { + db, err := sql.Open("ydb", "grpcs://login:password@localohost:2135/local") + if err != nil { + panic(err) + } + defer db.Close() + ... +} +``` diff --git a/ydb/docs/_includes/go/auth-static-with-database-sql.md b/ydb/docs/_includes/go/auth-static-with-database-sql.md new file mode 100644 index 0000000000..cb773bf8ec --- /dev/null +++ b/ydb/docs/_includes/go/auth-static-with-database-sql.md @@ -0,0 +1,30 @@ +```go +package main + +import ( + "context" + "os" + + "github.com/ydb-platform/ydb-go-sdk/v3" +) + +func main() { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + nativeDriver, err := ydb.Open(ctx, + os.Getenv("YDB_CONNECTION_STRING"), + ydb.WithStaticCredentials("user", "password"), + ) + if err != nil { + panic(err) + } + defer nativeDriver.Close(ctx) + connector, err := ydb.Connector(nativeDriver) + if err != nil { + panic(err) + } + db := sql.OpenDB(connector) + defer db.Close() + ... +} +``` diff --git a/ydb/docs/_includes/go/auth-static-with-native.md b/ydb/docs/_includes/go/auth-static-with-native.md new file mode 100644 index 0000000000..0102f8984e --- /dev/null +++ b/ydb/docs/_includes/go/auth-static-with-native.md @@ -0,0 +1,24 @@ +```go +package main + +import ( + "context" + "os" + + "github.com/ydb-platform/ydb-go-sdk/v3" +) + +func main() { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + db, err := ydb.Open(ctx, + os.Getenv("YDB_CONNECTION_STRING"), + ydb.WithStaticCredentials("user", "password"), + ) + if err != nil { + panic(err) + } + defer db.Close(ctx) + ... +} +``` diff --git a/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-static.md b/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-static.md index 845d5c9573..b5a89d5407 100644 --- a/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-static.md +++ b/ydb/docs/en/core/reference/ydb-sdk/recipes/auth-static.md @@ -23,89 +23,24 @@ Below are examples of the code for authentication based on a username and token - Go (native) You can pass the username and password in the connection string. For example: + ```shell "grpcs://login:password@localohost:2135/local" ``` You can also explicitly pass them using the `ydb.WithStaticCredentials` parameter: - ```go - package main - - import ( - "context" - "os" - - "github.com/ydb-platform/ydb-go-sdk/v3" - ) - - func main() { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - db, err := ydb.Open(ctx, - os.Getenv("YDB_CONNECTION_STRING"), - ydb.WithStaticCredentials("user", "password"), - ) - if err != nil { - panic(err) - } - defer db.Close(ctx) - ... - } - ``` + + {% include [auth-static-with-native](../../../../_includes/go/auth-static-with-native.md) %} - Go (database/sql) You can pass the username and password in the connection string. For example: - ```go - package main - - import ( - "context" - - _ "github.com/ydb-platform/ydb-go-sdk/v3" - ) - - func main() { - db, err := sql.Open("ydb", "grpcs://login:password@localohost:2135/local") - if err != nil { - panic(err) - } - defer db.Close() - ... - } - ``` + + {% include [auth-static-database-sql](../../../../_includes/go/auth-static-database-sql.md) %} You can also explicitly pass the username and password at driver initialization via a connector using the `ydb.WithStaticCredentials` parameter: - ```go - package main - - import ( - "context" - "os" - - "github.com/ydb-platform/ydb-go-sdk/v3" - ) - - func main() { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - nativeDriver, err := ydb.Open(ctx, - os.Getenv("YDB_CONNECTION_STRING"), - ydb.WithStaticCredentials("user", "password"), - ) - if err != nil { - panic(err) - } - defer nativeDriver.Close(ctx) - connector, err := ydb.Connector(nativeDriver) - if err != nil { - panic(err) - } - db := sql.OpenDB(connector) - defer db.Close() - ... - } - ``` + + {% include [auth-static-with-database-sql](../../../../_includes/go/auth-static-with-database-sql.md) %} - Java @@ -126,5 +61,4 @@ Below are examples of the code for authentication based on a username and token } ``` - {% endlist %} diff --git a/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-static.md b/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-static.md index 5976bf7230..e438538fd1 100644 --- a/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-static.md +++ b/ydb/docs/ru/core/reference/ydb-sdk/recipes/auth-static.md @@ -23,89 +23,24 @@ - Go (native) Передать логин и пароль можно в составе строки подключения. Например, так: + ```shell "grpcs://login:password@localohost:2135/local" ``` Также можно передать логин и пароль явно через опцию `ydb.WithStaticCredentials`: - ```go - package main - - import ( - "context" - "os" - - "github.com/ydb-platform/ydb-go-sdk/v3" - ) - - func main() { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - db, err := ydb.Open(ctx, - os.Getenv("YDB_CONNECTION_STRING"), - ydb.WithStaticCredentials("user", "password"), - ) - if err != nil { - panic(err) - } - defer db.Close(ctx) - ... - } - ``` + + {% include [auth-static-with-native](../../../../_includes/go/auth-static-with-native.md) %} - Go (database/sql) Передать логин и пароль можно в составе строки подключения. Например, так: - ```go - package main - - import ( - "context" - - _ "github.com/ydb-platform/ydb-go-sdk/v3" - ) - - func main() { - db, err := sql.Open("ydb", "grpcs://login:password@localohost:2135/local") - if err != nil { - panic(err) - } - defer db.Close() - ... - } - ``` + + {% include [auth-static-database-sql](../../../../_includes/go/auth-static-database-sql.md) %} Также можно передать логин и пароль явно при инициализации драйвера через коннектор с помощью специальной опции `ydb.WithStaticCredentials`: - ```go - package main - - import ( - "context" - "os" - - "github.com/ydb-platform/ydb-go-sdk/v3" - ) - - func main() { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - nativeDriver, err := ydb.Open(ctx, - os.Getenv("YDB_CONNECTION_STRING"), - ydb.WithStaticCredentials("user", "password"), - ) - if err != nil { - panic(err) - } - defer nativeDriver.Close(ctx) - connector, err := ydb.Connector(nativeDriver) - if err != nil { - panic(err) - } - db := sql.OpenDB(connector) - defer db.Close() - ... - } - ``` + + {% include [auth-static-with-database-sql](../../../../_includes/go/auth-static-with-database-sql.md) %} - Java |