Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
MikhailNazarov committed Oct 4, 2024
1 parent 4743588 commit 94be22d
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,41 @@ This crate provides Sqlx integration for [ydb-rs-sdk](https://github.com/ydb-pla

## Basic examples

### Connection from .env

You could use `DATABASE_URL` or `YDB_CONNECTION_STRING` environment variable to connect to ydb server.

```.env
YDB_CONNECTION_STRING=grpc://localhost:2136?database=/local
```

```.env
DATABASE_URL=grpcs://ydb.serverless.yandexcloud.net:2135/?database=/ru-central1/xxxxxxxxxxxxxxx/yyyyyyyyyy&connection_timeout=5&sa-key=./key.json
```

```rust
let pool = Ydb::connect_env().await?;
```

### Connection options

```rust
let pool = Ydb::connect_env_opts(|opt|opt.log_statements(LevelFilter::Info)).await?;
```

### Connection from url

```rust
let pool = Ydb::connect("grpc://localhost:2136?database=/local").await?;
```

or

```rust
let pool = Ydb::connect_opts("grpc://localhost:2136?database=/local", |opt|opt.log_statements(LevelFilter::Info)).await?;
```

### Simple select
```rust
#[tokio::main]
Expand Down

0 comments on commit 94be22d

Please sign in to comment.