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

    ImportError: no module named 'MySQLdb'

    Scheduled Pinned Locked Moved LoPy
    mysqlpymakrlopydatabase
    6 Posts 3 Posters 1.6k Views 3 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.
    • F Offline
      Fajriansyah
      last edited by

      I use pymakr to connect my LoPy with MySQLdb but there is error ( ImportError: no module named 'MySQLdb' ) what am I suppose to do?
      my code is:
      import MySQLdb

      db = MySQLdb.connect(host="localhost", # your host, usually localhost
      user="root", # your username
      passwd="", # your password
      db="solarchargermonitoring") # name of the data base

      you must create a Cursor object. It will let

      you execute all the queries you need

      cur = db.cursor()

      Use all the SQL you like

      cur.execute("SELECT * from regisperangkat")

      print all the first cell of all the rows

      for row in cur.fetchall():
      print(row)

      db.close()

      J L 2 Replies Last reply Reply Quote 0
      • J Offline
        jcaron @Fajriansyah
        last edited by

        @fajriansyah you most certainly won’t be running a MySQL server on a LoPy, and I’m not sure there are any scenarios where it would make sense to connect directly to one from a LoPy either. Calling a webservice or sending data over LoRa to a server which would in turn connect to a MySQL database would probably make more sense.

        What exactly are you trying to achieve?

        1 Reply Last reply Reply Quote 0
        • L Offline
          livius @Fajriansyah
          last edited by

          @fajriansyah
          You probably mismatch things
          on Lopy you have micropython not full python because hardware resources are too limited.

          think about people first, then computers

          F 1 Reply Last reply Reply Quote 0
          • F Offline
            Fajriansyah @livius
            last edited by Fajriansyah

            @livius @jcaron sorry, I mean lopy will connect with my database (local host). Can it?

            L 1 Reply Last reply Reply Quote 0
            • F Offline
              Fajriansyah
              last edited by

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • L Offline
                livius @Fajriansyah
                last edited by

                @fajriansyah
                I do not know if some "minimal" client exists for micropython. But is it required?
                Better run some listen socket on your server. And then your Lopy will send messages to this socket and it connect to jour database and store there data. It can be e.g. windows service apllication, webserver application e.g. on IIS, Apache + php ....

                think about people first, then computers

                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