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
-
@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.
-
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.
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