Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Mongo db with Pycom GPy

    Scheduled Pinned Locked Moved Discussion
    databasegpy
    7 Posts 4 Posters 1.1k Views 5 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      sprasad
      last edited by

      Hello,
      I'm trying to access mongo db with my GPy board. I have used PyMongo library before to access mongo db in my python scripts. But for that, I had installed PyMongo using pip install on my system. How can I achieve the same using GPy board? Pointers to any examples of pycom boards accessing dbs would also be helpful.

      J 1 Reply Last reply Reply Quote 0
      • sebS Offline
        seb
        last edited by

        A quick google search for "mongodb micropython" brought up this: https://github.com/nakagami/nmongo

        1 Reply Last reply Reply Quote 0
        • S Offline
          sprasad
          last edited by

          Thanks for the pointer! I uploaded required files onto the board and tried running the example commands from the shell and got this error

          AttributeError: 'module' object has no attribute 'connect' 
          

          Tried to search online but seems like not many people have tried this out! Any tried and tested version of the same?

          1 Reply Last reply Reply Quote 0
          • sebS Offline
            seb
            last edited by

            can you run the following and post back the output:

            import nmongo
            print(dir(nmongo))
            

            It could be that the library did not upload correctly and hence doesnt work. It might be wirth connecting via FTP and checking the file contents are complete

            1 Reply Last reply Reply Quote 0
            • J Offline
              jcaron @sprasad
              last edited by

              @sprasad Not sure what your use case is, but in general it would probably be more appropriate for the GPy to call a webservice on a server, and have that server connect to the database, rather than trying to connect directly to the database from the GPy.

              But of course YMMV.

              1 Reply Last reply Reply Quote 1
              • T Offline
                TravisT
                last edited by

                I would agree with @jcaron. What would be easier is to communicate to some sort of backend, like Flask, that parses your data and stores it. A good example would be using a Flask server with MQTT and Mongo, then you can use MQTT from the Gpy to send data back and forth to the backend. This pulls a lot of the overhead on your resourced constrained Gpy.

                1 Reply Last reply Reply Quote 0
                • S Offline
                  sprasad
                  last edited by

                  @TravisT @jcaron Thank you guys! That is exactly what we decided to do. Connect to a webservice on the internet with wifi and make that communicate with the database.

                  1 Reply Last reply Reply Quote 0

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better šŸ’—

                  Register Login
                  • 1 / 1
                  • First post
                    Last post

                  Pycom on Twitter

                  Pycom