Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
psarna authored Oct 6, 2023
1 parent 383333a commit b92e67b
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ At the moment the library works with the following backends:

## Quickstart

In order to use the database in your project, just call `libsql_client::new_client()`:
In order to use the database in your project, just call `libsql_client::Client::from_env()`, or any of the other [constructors](https://docs.rs/libsql-client/latest/libsql_client/client/enum.Client.html):
```rust
let db = libsql_client::new_client().await?;
let db = libsql_client::Client::from_env().await?;
```

The only thing you need to provide is an env variable with the database URL, e.g.
Expand Down Expand Up @@ -48,28 +48,6 @@ Example for how to connect to the database and perform a query:
(...)
```


### Reqwest
In order to connect to the database, set up the following env variables:
```
export LIBSQL_CLIENT_URL = "https://your-db-url.example.com"
export LIBSQL_CLIENT_TOKEN = "<your-jwt>"
```

`reqwest_backend` feature is enabled by default, so add the dependency like this:
```
cargo add libsql-client
```

Example for how to connect to the database and perform a query from a GET handler:
```rust
let db = libsql_client::reqwest::Client::from_env()?;
let response = db
.execute("SELECT * FROM table WHERE key = 'key1'")
.await?;
(...)
```

### Cloudflare Workers

In order to connect to the database, set up the following variables in `.dev.vars`, or register them as secrets:
Expand Down

0 comments on commit b92e67b

Please sign in to comment.