5 releases (3 breaking)

0.4.0 Nov 25, 2024
0.3.0 Oct 4, 2023
0.2.0 Oct 3, 2023
0.0.1 Oct 2, 2023
0.0.0 Oct 2, 2023

#497 in Database interfaces

Download history 5/week @ 2024-09-23 155/week @ 2024-11-25 15/week @ 2024-12-02 24/week @ 2024-12-09

194 downloads per month
Used in dbmigrator_cli

MIT license

44KB
922 lines

Parser for PostgreSQL dumps in custom format

This crate allows inspecting the contents of a PostgreSQL backup as made using pg_dump -Fc or pg_dump --format=custom, and provides direct access all raw table data. This can be useful if you do not trust the SQL statements embedded in the dump, or if you want to process data without loading it into a database.

use std::fs::File;
use pgarchive::Archive;

let mut file = File::open("tests/test.pgdump").unwrap();
match Archive::parse(&mut file) {
    Ok(archive) => println!("This is a backup of {}", archive.database_name),
    Err(e) => println!("can not read file: {:?}", e),
};

lib.rs:

Parser for PostgreSQL dumps in custom format

This crate allows inspecting the contents of a PostgreSQL backup as made using pg_dump -Fc or pg_dump --format=custom, and provides direct access all raw table data. This can be useful if you do not trust the SQL statements embedded in the dump, or if you want to process data without loading it into a database.

use std::fs::File;
use pgarchive::Archive;

let mut file = File::open("tests/test.pgdump").unwrap();
match Archive::parse(&mut file) {
    Ok(archive) => println!("This is a backup of {}", archive.database_name),
    Err(e) => println!("can not read file: {:?}", e),
};

Dependencies

~1.5–2.2MB
~40K SLoC