Connecting WiPy 3.0 with a MySQL Database using uPyMySQL



  • Hello,

    i have a sensor that reports data and i need that data in a MySQL Database.
    After searching for a option to send these data directly i found: uPyMySQL.

    Someone has tried it before and could establish a connection?
    I am not even getting it to work so i hope someone tried it before.

    Cheers



  • I agree with @jcaron that it's not usually appropriate to write directly to a remote database from an IoT sensor. Most instead use a protocol such as MQTT to communicate, as it was designed for this type of application. You can use an MQTT broker (such as Mosquitto) to receive messages and write them to your mysql database.



  • @int it is quite unusual to talk to a SQL database directly from an IoT sensor, especially as this requires direct two-way IP connectivity (which in turn eliminates some network technologies such as LoRa, Sigfox, BLE...) and often higher bandwidth (and processing) requirements.

    Wouldn’t it be better if your sensor sent the data to a server (using a webservice if over IP, or the relevant protocol for other technologies), and then that server would talk to the SQL database?

    This also makes your sensor less dependant on any schema changes and simplifies security.

    Not saying that’s the only way to do it, but in the majority of cases it’s the better way.


Log in to reply
 

Pycom on Twitter