Skip to content

Commit f484d8d

Browse files
committed
Documentation updates
1 parent c0280f3 commit f484d8d

2 files changed

Lines changed: 54 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,7 @@ A very basic fixed-size connection pool is provided in the `pool` module. A
179179
single pool can be shared across tasks and `get_connection` will block until a
180180
connection is available.
181181
```rust
182-
let pool = PostgresConnectionPool::new("postgres://postgres@localhost", 5)
183-
.unwrap();
182+
let pool = PostgresConnectionPool::new("postgres://postgres@localhost", 5);
184183

185184
for _ in range(0, 10) {
186185
do task::spawn_with(pool.clone()) |pool| {

src/postgres/lib.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,56 @@
1+
/*!
2+
Rust-Postgres is a pure-Rust frontend for the popular PostgreSQL database. It
3+
exposes a high level interface in the vein of JDBC or Go's `database/sql`
4+
package.
5+
6+
```rust
7+
extern mod postgres;
8+
9+
use postgres::PostgresConnection;
10+
use postgres::types::ToSql;
11+
12+
#[deriving(ToStr)]
13+
struct Person {
14+
id: i32,
15+
name: ~str,
16+
awesome: bool,
17+
data: Option<~[u8]>
18+
}
19+
20+
fn main() {
21+
let conn = PostgresConnection::connect("postgres://postgres@localhost");
22+
23+
conn.update("CREATE TABLE person (
24+
id SERIAL PRIMARY KEY,
25+
name VARCHAR NOT NULL,
26+
awesome BOOL NOT NULL,
27+
data BYTEA
28+
)", []);
29+
let me = Person {
30+
id: 0,
31+
name: ~"Steven",
32+
awesome: true,
33+
data: None
34+
};
35+
conn.update("INSERT INTO person (name, awesome, data)
36+
VALUES ($1, $2, $3)",
37+
[&me.name as &ToSql, &me.awesome as &ToSql,
38+
&me.data as &ToSql]);
39+
40+
let stmt = conn.prepare("SELECT id, name, awesome, data FROM person");
41+
for row in stmt.query([]) {
42+
let person = Person {
43+
id: row[0],
44+
name: row[1],
45+
awesome: row[2],
46+
data: row[3]
47+
};
48+
println!("Found person {}", person.to_str());
49+
}
50+
}
51+
```
52+
*/
53+
154
#[desc="A native PostgreSQL driver"];
255
#[license="MIT"];
356

0 commit comments

Comments
 (0)