This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pymongo import MongoClient | |
from random import randint | |
#Step 1: Connect to MongoDB - Note: Change connection string as needed | |
client = MongoClient(port=27017) | |
db=client.business | |
#Step 2: Create sample data | |
names = ['Kitchen','Animal','State', 'Tastey', 'Big','City','Fish', 'Pizza','Goat', 'Salty','Sandwich','Lazy', 'Fun'] | |
company_type = ['LLC','Inc','Company','Corporation'] | |
company_cuisine = ['Pizza', 'Bar Food', 'Fast Food', 'Italian', 'Mexican', 'American', 'Sushi Bar', 'Vegetarian'] | |
for x in xrange(1, 501): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pymongo import MongoClient | |
# Connect to the MongoDB, change the connection string per your MongoDB environment | |
client = MongoClient(port=27017) | |
# Set the db object to point to the business database | |
db=client.business | |
# Showcasing the count() method of find, count the total number of 5 ratings | |
print('The number of 5 star reviews:') | |
fivestarcount = db.reviews.find({'rating': 5}).count() | |
print(fivestarcount) | |
# Not let's use the aggregation framework to sum the occurrence of each rating across the entire data set |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pymongo import MongoClient | |
#include pprint for readabillity of the | |
from pprint import pprint | |
#change the MongoClient connection string to your MongoDB database instance | |
client = MongoClient(port=27020) | |
db=client.business | |
ASingleReview = db.reviews.find_one({}) | |
print('A sample document:') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pymongo import MongoClient | |
# pprint library is used to make the output look more pretty | |
from pprint import pprint | |
# connect to MongoDB, change the << MONGODB URL >> to reflect your own connection string | |
client = MongoClient(<<MONGODB URL>>) | |
db=client.admin | |
# Issue the serverStatus command and print the results | |
serverStatusResult=db.command("serverStatus") | |
pprint(serverStatusResult) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from umqtt.simple import MQTTClient | |
import network | |
import machine | |
import time | |
import socket | |
import utime | |
ssid=#Put your SSID name here | |
pwd=#Put your WiFi password here | |
device_name='TempSensor1' #Put the name of the device here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib; | |
import hmac; | |
import datetime; | |
import paho.mqtt.client as mqtt | |
import json | |
import calendar | |
import requests | |
mqqt_server=#enter your mqqt server here | |
mqqt_port=1883 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports = function(payload,response) { | |
const mongodb = context.services.get("mongodb-atlas"); | |
const sensordata = mongodb.db("iotdb").collection("sensordata"); | |
var body = {}; | |
if (payload.body) { | |
try{ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.Azure.WebJobs; | |
using Microsoft.Azure.WebJobs.Extensions.Http; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.Azure.WebJobs.Host; | |
using Microsoft.Extensions.Logging; | |
using Newtonsoft.Json; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using MongoDB.Bson; | |
using MongoDB.Driver; | |
using MongoDB.Bson.Serialization.Attributes; | |
namespace MongoDBTransaction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mongodb = require("mongodb"); | |
run().catch(error => console.error(error)); | |
async function run() { | |
console.log(new Date(), "Connecting to localhost"); | |
const uri = "mongodb://127.0.0.1:27017/test?replicaSet=repl0"; | |
const client = await mongodb.MongoClient.connect( | |
uri, | |
function(err, client) { |
OlderNewer