| Crates.io | polars_bson |
| lib.rs | polars_bson |
| version | 0.1.0 |
| created_at | 2025-05-03 14:53:06.916396+00 |
| updated_at | 2025-05-03 14:53:06.916396+00 |
| description | Provides a BsonReader similar to Polars' JsonReader to read in a cursor of MongoDB Bson documents from a collection and a find query into a polars DataFrame. |
| homepage | |
| repository | https://github.com/trxe/polars_bson |
| max_upload_size | |
| id | 1658859 |
| size | 122,916 |
polars_bson: A MongoDB Bson reader for polarsStill a work in progress, will be slowly implementing:
infer_schema_len, n_threads etc.WARNING: The interface for
BsonReaderis still WIP as well. Subject to changes in architecture.
use bson::doc;
use chrono::Utc;
use crate::{BsonReader, common::BsonDoc};
const MONGO_URI: &str = "mongodb://localhost:27017";
const MONGO_DEFAULT_DB: &str = "csdb";
fn main() {
dotenvy::dotenv().unwrap();
let modb = match std::env::var("MONGO_LIVEDB") {
Ok(x) => x,
Err(_) => {
return;
}
};
let client = mongodb::sync::Client::with_uri_str(modb).expect("client not built");
let db = client.database(MONGO_DEFAULT_DB);
let collection = db.collection::<BsonDoc>("transactions");
let df = BsonReader::new(collection, doc! {"team.id": 1})
.finish()
.unwrap();
println!("{df:?}");
}