postgres_large_object

Crates.iopostgres_large_object
lib.rspostgres_large_object
version0.7.1
sourcesrc
created_at2015-02-16 06:55:08.674376
updated_at2018-03-06 02:50:04.280577
descriptionLarge object support for rust-postgres
homepage
repositoryhttps://github.com/sfackler/rust-postgres-large-object
max_upload_size
id1412
size29,084
cargo publish (github:servo:cargo-publish)

documentation

https://docs.rs/postgres_large_object/0.7.0/postgres_large_object

README

rust-postgres-large-object

CircleCI

Documentation

A crate providing access to the Postgres large object API.

Example

extern crate postgres;
extern crate postgres_large_object;

use std::fs::File;
use std::io;

use postgres::{Connection, TlsMode};
use postgres_large_object::{LargeObjectExt, LargeObjectTransactionExt, Mode};

fn main() {
    let conn = Connection::connect("postgres://postgres@localhost", TlsMode::None).unwrap();

    let mut file = File::open("vacation_photos.tar.gz").unwrap();
    let trans = conn.transaction().unwrap();
    let oid = trans.create_large_object().unwrap();
    {
        let mut large_object = trans.open_large_object(oid, Mode::Write).unwrap();
        io::copy(&mut file, &mut large_object).unwrap();
    }
    trans.commit().unwrap();

    let mut file = File::create("vacation_photos_copy.tar.gz").unwrap();
    let trans = conn.transaction().unwrap();
    let mut large_object = trans.open_large_object(oid, Mode::Read).unwrap();
    io::copy(&mut large_object, &mut file).unwrap();
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.

Commit count: 73

cargo fmt