Mongodb allows you to query a specific column in a relational database.

Source: Internet
Author: User
Recently, the find () method in tornadomongodbansiblemongodb is awesome. You can upload all the tables in the set. At first I wrote classModule_actionHandler (tornado. web. requestHandler): defget (self, * args, ** kwargs): collself. application. db. waitfishhostscol

Recently, there was a find () method in tornado \ mongodb \ ansible mongodb, which was awesome. You can upload all the tables in the set. At first I wrote class Module_actionHandler (tornado. web. requestHandler): def get (self, * args, ** kwargs): coll = self. application. db. waitfish hosts = col

Recently in tornado \ mongodb \ ansible

The find () method in mongodb is awesome. You can upload all the tables in the set.

class Module_actionHandler(tornado.web.RequestHandler):    def get(self, *args, **kwargs):        coll = self.application.db.waitfish        hosts = coll.find({}, {'hostname':1,"_id":0})        modulenames = ['ping', 'setup', 'copy']        self.render(            "module_action.html",            hosts = hosts,            modulenames = modulenames,        )
Then in the template:
                {% for host in hosts %}                {{ host['hostname'] }}                {% end %}
Later I thought about the find () method to find all the tables, which is too much damage ..

So I went to see du Niang again, basically listing a lot of query commands and a lot of methods.

Finally, I chose this one:

Class Module_actionHandler (tornado. web. requestHandler): def get (self, * args, ** kwargs): coll = self. application. db. waitfish hosts = coll. find ({},{ 'hostname': 1, "_ id": 0}) # To explain, Here hostname: 1 indicates that the hostname column is returned, because the _ id column is returned every time, 0 is disabled. The template is also modulenames = ['ping', 'setup', 'copy'] self. render ("module_action.html", hosts = hosts, modulenames = modulenames ,)
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.