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.2.tar.gz
(5.6 kB
view hashes)
Built Distribution
Close
Hashes for dask_mongo-2021.7.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a93b671f4401b0168a19107cbf454fb94bb46f421b5efbf9e770640af1c74e8 |
|
MD5 | 20855c75ea1e50b37b1950c2e47c68ff |
|
BLAKE2b-256 | 4a2b923be2ba88af244a4d42316c6c9fdbb7ae2d5fee996ec6bcde95839bc5b3 |