Storing weather in MongoDB

While back I posted and shared my weather collection using Open Weather API and storing the data into MySQL database, here was my original post.

Now this time I am posting how to download weather using Yahoo Weather API and storing the data into a MongoDB database.

You will need to to register and obtain a Yahoo Weather API from here first before you can continue and use the script I am providing in this post šŸ™‚

Here are a few screenshots showing me download and storing the weather information in MongoDB this time.


Now that you’ve seen me collecting the Weather report lets take a look at the mongo client with a couple of screenshots also, first the standard command line and the second one using Robo 3t a MongoDB GUI client.


The above and bellow query is simply listing the last 3 entries in the database in case you wondering.

> db.w_records.find().limit(3).sort({$natural:-1})
> db.w_records.find({‘TimeZone’ : ‘Europe/Amsterdam’},{‘_id’:0})

Robo 3t

Now, let’s give you the tools you need to make this happen.
First, you create a connection file that contains details of your MongoDB database, Table “Documents” and Manager link.
This example will not contact DB user or password so there is no security but feel free to modify as you see fit.
Probably worth noting that the script and connection file weather collectors are php scripts.

  1. Connection file. here
  2. Weather script. here

You will need to know the basics of PHP and perhaps a little about MongoDB but if you don’t, don’t worry as it is not a problem as it can very easily be pickup to run this script.

Anyway I hope you found it useful and helpful in some way shapre or form šŸ˜‰

Any questions or suggestions please feel free to ping on twitter @gcclinux