mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-22 16:29:20 +08:00
README: nudge people towards bundled, use tuple params, remove comment about rust-postgres
This commit is contained in:
parent
2ec0b2e8fe
commit
5923d0c8bd
28
README.md
28
README.md
@ -8,11 +8,29 @@
|
||||
[![Dependency Status](https://deps.rs/repo/github/rusqlite/rusqlite/status.svg)](https://deps.rs/repo/github/rusqlite/rusqlite)
|
||||
[![Discord Chat](https://img.shields.io/discord/927966344266256434.svg?logo=discord)](https://discord.gg/nFYfGPB8g4)
|
||||
|
||||
Rusqlite is an ergonomic wrapper for using SQLite from Rust. It attempts to expose
|
||||
an interface similar to [rust-postgres](https://github.com/sfackler/rust-postgres).
|
||||
Rusqlite is an ergonomic wrapper for using SQLite from Rust.
|
||||
|
||||
## Usage
|
||||
|
||||
In your Cargo.toml:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
# `bundled` causes us to automatically compile and link in an up to date
|
||||
# version of SQLite for you, which avoids many common build issues, and
|
||||
# avoids depending on the version of SQLite on the users system, which may
|
||||
# be old or missing. However, it's not ideal for all scenarios and in
|
||||
# particular, generic libraries built around `rusqlite` should probably
|
||||
# not enable it; it's a choice that should *usually* be left up to
|
||||
# the application that actually manages the database, which is why it
|
||||
# is not a default feature.
|
||||
rusqlite = { version = "0.27.0", features = ["bundled"] }
|
||||
```
|
||||
|
||||
Simple example usage:
|
||||
|
||||
```rust
|
||||
use rusqlite::{params, Connection, Result};
|
||||
use rusqlite::{Connection, Result};
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Person {
|
||||
@ -30,7 +48,7 @@ fn main() -> Result<()> {
|
||||
name TEXT NOT NULL,
|
||||
data BLOB
|
||||
)",
|
||||
[], // empty list of parameters.
|
||||
(), // empty list of parameters.
|
||||
)?;
|
||||
let me = Person {
|
||||
id: 0,
|
||||
@ -39,7 +57,7 @@ fn main() -> Result<()> {
|
||||
};
|
||||
conn.execute(
|
||||
"INSERT INTO person (name, data) VALUES (?1, ?2)",
|
||||
params![me.name, me.data],
|
||||
(&me.name, &me.data),
|
||||
)?;
|
||||
|
||||
let mut stmt = conn.prepare("SELECT id, name, data FROM person")?;
|
||||
|
Loading…
Reference in New Issue
Block a user