mirror of
https://github.com/isar/rusqlite.git
synced 2025-03-29 00:32:57 +08:00
Remove use of time
crate in README.md
This commit is contained in:
parent
004c8f23d4
commit
edceb01747
14
README.md
14
README.md
@ -12,13 +12,11 @@ an interface similar to [rust-postgres](https://github.com/sfackler/rust-postgre
|
|||||||
|
|
||||||
```rust
|
```rust
|
||||||
use rusqlite::{params, Connection, Result};
|
use rusqlite::{params, Connection, Result};
|
||||||
use time::Timespec;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Person {
|
struct Person {
|
||||||
id: i32,
|
id: i32,
|
||||||
name: String,
|
name: String,
|
||||||
time_created: Timespec,
|
|
||||||
data: Option<Vec<u8>>,
|
data: Option<Vec<u8>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +27,6 @@ fn main() -> Result<()> {
|
|||||||
"CREATE TABLE person (
|
"CREATE TABLE person (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
time_created TEXT NOT NULL,
|
|
||||||
data BLOB
|
data BLOB
|
||||||
)",
|
)",
|
||||||
params![],
|
params![],
|
||||||
@ -37,22 +34,19 @@ fn main() -> Result<()> {
|
|||||||
let me = Person {
|
let me = Person {
|
||||||
id: 0,
|
id: 0,
|
||||||
name: "Steven".to_string(),
|
name: "Steven".to_string(),
|
||||||
time_created: time::get_time(),
|
|
||||||
data: None,
|
data: None,
|
||||||
};
|
};
|
||||||
conn.execute(
|
conn.execute(
|
||||||
"INSERT INTO person (name, time_created, data)
|
"INSERT INTO person (name, data) VALUES (?1, ?2)",
|
||||||
VALUES (?1, ?2, ?3)",
|
params![me.name, me.data],
|
||||||
params![me.name, me.time_created, me.data],
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let mut stmt = conn.prepare("SELECT id, name, time_created, data FROM person")?;
|
let mut stmt = conn.prepare("SELECT id, name, data FROM person")?;
|
||||||
let person_iter = stmt.query_map(params![], |row| {
|
let person_iter = stmt.query_map(params![], |row| {
|
||||||
Ok(Person {
|
Ok(Person {
|
||||||
id: row.get(0)?,
|
id: row.get(0)?,
|
||||||
name: row.get(1)?,
|
name: row.get(1)?,
|
||||||
time_created: row.get(2)?,
|
data: row.get(2)?,
|
||||||
data: row.get(3)?,
|
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user