GitXplorerGitXplorer
j

rust-postgres-cursor

public
12 stars
2 forks
1 issues

Commits

List of commits on branch master.
Unverified
8db8ca0096391a33232926beb23972af130c830b

Bump version

jjwilm committed 3 years ago
Verified
0ac6b115f002d6beedbf8ee8031bbb1f34db9036

Update project's dependencies (#6)

committed 3 years ago
Unverified
3cb8313521aa5aad87a6ee7b6a5ae69b23fed2c5

Release 0.3.0

jjwilm committed 7 years ago
Unverified
37c50bec23fa45964dd980f756fea820b21f1d2f

Update for rust-postgres = 0.15.1 (#4)

ssd2k committed 7 years ago
Unverified
562191055ec5cea7bfc3bb3d5ea164d89e2ee4a9

Fix README; prepare for crates.io README render

jjwilm committed 7 years ago
Unverified
8c0d128218264a7f0a918c93b9cd17b283237eec

Add IntoIterator implementation for &mut Cursor

jjwilm committed 7 years ago

README

The README file for this repository.

rust-postgres-cursor

A cursor type for use with PostgreSQL.

Example

extern crate postgres;
extern crate postgres_cursor;

use postgres::{Client, NoTls};
use postgres_cursor::Cursor;

// First, establish a connection with postgres
let mut client = Client::connect("postgres://jwilm@127.0.0.1/foo", NoTls)
    .expect("connect");

// Build the cursor
let mut cursor = Cursor::build(&mut client)
    // Batch size determines rows returned in each FETCH call
    .batch_size(10)
    // Query is the statement to build a cursor for
    .query("SELECT id FROM products")
    // Finalize turns this builder into a cursor
    .finalize()
    .expect("cursor creation succeeded");

// Iterate over batches of rows
for result in &mut cursor {
    // Each item returned from the iterator is a Result<Vec<Row>, postgres::Error>.
    // This is because each call to `next()` makes a query
    // to the database.
    let rows = result.unwrap();

    // After handling errors, rows returned in this iteration
    // can be iterated over.
    for row in &rows {
        println!("{:?}", row);
    }
}