Send data to MongoDB
Tags: #googlesheets #mongodb #nosql #operations #automation
This notebook will help you send data from your spreadsheet to your MongoDB database collection
from naas_drivers import mongo, gsheet
import pandas as pd
import naas
- Share your Google Sheet with our service account : 🔗 [email protected]
spreadsheet_id = "------"
sheet_name = "Sheet1"
- Get your user, password and connection URL details from your MongoDB Atlas Cluster
user = "your user"
passwd = "your password"
host = "Your Connection URL"
port = 9090
collection_name = "COLLECTION NAME"
db_name = "DATABASE NAME"
naas.scheduler.add(
cron="0 9 * * *"
) # Send in production this notebook and run it, every day at 9:00.
# use this to delete your automation
# naas.scheduler.delete()
df = gsheet.connect(spreadsheet_id).get(sheet_name=sheet_name)
mongo.connect(host, port, user, passwd).send(df, collection_name, db_name, replace=True)
Last modified 1mo ago