Showing posts with label data. Show all posts
Showing posts with label data. Show all posts

Tuesday, March 31, 2015

MongoDB find() and findOne() methods



     In  MongoDB CRUD operation find() and findOne() methods are used to read a documents from the collections. Lets study this methods with example. 

1. find() : 
                  The most basic operation to query documents out of the database is called find(). MongoDB find() method returns all documents present in the database.
 For example, Here I have student database and collection name is grades which has 800 documents. After executing this query it returns first 10 documents and it ask for next 10 documents. If you want more documents type "it" next 10 documents will get display.

    find() method can take some arguments. You can filter result by adding search criteria. For example in "grades" collection there are "homework","quiz" and "exam " type of documents. If I want only "exam" type . The query will be db.grades.find({''type'' :''exam''}).




       We can also add multiple fields in criteria but both the criteria should match. Like here I have selected students with type :exam and you can also include and exclude fields if you want by making field name true or false, here I excluded object id field.





  2. findOne():

 This method also retrieves the data but it returns only one document at a time. Lets see following example fineOne() without argument returns very first document from the collection.



  We can also add criteria in findOne() method like find() method. In following example only document with the "student_id" : 112 is return as specified in criteria.




         









Wednesday, July 10, 2013

Gmail Account Backup in Ubuntu

We always hear about backing up your data, because data is so important to us, but do we have ever think about backing up our web based email? There is a way we can use it to backup our Gmail account.

In windows, there are many applications like Thunderbird and GMVault, which you can use to backup your Gmail account. But how to do the same thing in Linux based operating system? Linux operating system also supports Thunderbird to back up the Gmail account, but there is a better alternative known as Getmail. Getmail is compatible with all Linux versions.

Now we'll see how to back up the Gmail account. This demo is done on Ubuntu 11.10 version of Linux.

 Ubuntu users can easily download and install getmail from Ubuntu Software Center. Other Linux users can get it from download getmail .

Fig:1


After downloading, you have to create a configuration directory, a directory to store mbox file. To do this, open a terminal window and type the following command:-
 
       mkdir –m 0700 $HOME/.getmail

To create a directory for the mbox file that will be filled with your Gmail messages, type the following command. We can give other name also for the directory of your choice instead of “gmail-archive”.

       mkdir –m 0700 $HOME/gmail-archive

Now, you must create mbox file to contain the download messages. Getmail does not do this by its own. WE have to create it by typing the following command:-

      touch ~/gmail-archive/gmail-backup.mbox

Next, we have to create the configuration file to tell Getmail about your Gmail account. Open a text editor, such as gedit and copy the following commands into the file.

     [retriever]
     type = SimplePOP3SSLRetriever
     server = pop.gmail.com
     username = yourname@gmail.com 
     password = yourpassword
     [destination]
     type = Mboxrd
     path = ~/gmail-archive/gmail-backup.mbox
     [options]
     verbose = 2
     message_log = ~/.getmail/gmail.log



                                                                             Fig:2

Put the username and password of your Gmail account. And if you used a different directory and filename for the mbox file then change the path accordingly.

Then save the file as “.getmail/getmailrc”.

                                                                      Fig:3

Then run Getmail, by typing getmail in the terminal. Then you'll get all your Gmail messages.

                                                                      Fig:4

When Getmail finishes all downloading of the messages, you can see the contents in the mbox file.

                                                                        Fig:5



Thursday, January 10, 2013

SyncBox: Make Your Own Personal Cloud Storage Network On Your Hard Disk


Cloud storage services are designed to serve two primary purposes i.e. to provide a place to securely and reliably backup your important files, and from where these files will be available to all your devices at all times. But space factor becomes a matter of concern in these types of services and also the cost for extra storage, although it is cheap but we have to pay for this. The other factor is security. We may store a sensitive data on cloud storage network and the security provided by the cloud service providers may not so good to secure your highly sensible data.

So if you don’t trust cloud hosting services or you want to store a large amount of data, you are usually better using a service that lets you host your own cloud space on the Internet. There is a way of Cloud hosting service ownCloud that you can use to set up your own storage space on the Internet. The other way is that you can set up a cloud storage space network on your hard disk. You can do this by Syncbox. In this, instead of having to install the service on a server on the Internet, you can install it on your windows system. It then makes available the data on the Internet using dynamic IP service so that data can be accessed from remote locations provided the computer where we are storing our data is connected to the Internet.

 Syncbox offers server software that you need to install on your personal computer where you will store your data. And this server installer is only available for Windows, but the client programs covers a wide range of platforms like Windows, Mac OSX, Ubuntu, Android devices. To get started, first download and install sever application n your PC. You can download it from http://www.isyncbox.com/download.  This installation does not require much effort.

After installing, you will get the wizard screen as shown below. There are two options for you i.e. Quick Install and Custom Install. If you select Quick Install, the application assigns you a default Id and if you select Custom Install then you have to manually set up everything.
 
                                
 
I opt for Quick Install.
 
                            
 
 Give the password and you can also disable the viewing of your password and DDNS key and click next.



                             
 
Now the Syncbox server is established.
 
 
Once the configuration is done, the server resides on your system and hosts the selected drive location as cloud storage.
                               
 
From its right-click menu, you can see your Syncbox ID, access gallery and Event, open Syncbox Folder as well as open up Control panel. 
 

Then you can store your data to the hard drive you selected, that you can see on the Internet.
On the client side application for Windows doesn’t require any complicated configuration. You can download client side application from the above link.
 
 
After installing, you just need to assign your Syncbox ID and password to connect both Server and Client to each other.
 
 
Then you will see this screen, click on finish.
 
                              

Then from its right-click menu, you click on Link to this computer to connect with the server. Then you have just to give your server Syncbox ID and password and you get connect to the server.
 
Then from recent changed files you can see your data of your PC, which you had stored on your storage area.
 
This application is a two way synchronization, that means you can sync files from server to client and vice versa. Syncbox supports you to create your own cloud storage on your hard disk which is totally free of cost, access your files anytime, anywhere and you can get your data secured through privacy and also supports media streaming, simple sharing and collaboration and event management and version control guarantee and enhance file management.
Syncbox is an excellent software to make your hard drive work as a cloud.