Dask + Mongo intergration
Project description
Dask-Mongo
Read and write data to MongoDB with Dask
Installation
You can install dask-mongo
from PyPI
pip install dask-mongo
Example
import dask.bag as db
import dask_mongo
# Create Dask Bag
records = [
{"name": "Alice", "fruit": "apricots"},
{"name": "Bob", "fruit": ["apricots", "cherries"]},
{"name": "John", "age": 17, "sports": "cycling"},
]
b = db.from_sequence(records)
# Write to a Mongo database
dask_mongo.to_mongo(
b,
database="your_database",
collection="your_collection",
connection_kwargs={"host": "localhost", "port": 27017},
)
# Read Dask Bag from Mongo database
b = dask_mongo.read_mongo(
database="your_database",
collection="your_collection",
connection_kwargs={"host": "localhost", "port": 27017},
chunksize=2,
)
# Perform normal operations with Dask
names = b.pluck("name").compute()
assert names == ["Alice", "Bob", "John"]
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dask-mongo-2021.7.3.tar.gz
(5.6 kB
view hashes)
Built Distribution
Close
Hashes for dask_mongo-2021.7.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d1b7fa75833585f7f42838314209fd70efc99ad577578c1d9ec59d04b93ef6d |
|
MD5 | 26478255b27912441ff646e23b928a3f |
|
BLAKE2b-256 | 8a251e259da040307f10962b9bccd5c0bbf33e6fc5b2a509b3b454361ca8dd1c |