简体   繁体   English

从GPRS模块向桌面应用程序中的MySQL数据库发送数据

[英]Sending data to a MySQL database in a desktop application from a GPRS module

I want to develop a software which gets data periodically(daily) from a GPRS modem and saving it to a database(MySQL database) which is installed in a PC. 我想开发一种软​​件,该软件定期(每天)从GPRS调制解调器获取数据,并将其保存到PC上安装的数据库(MySQL数据库)中。 I would like to know a method to implement this. 我想知道一种实现此方法的方法。 My lecturer suggest me to use a cloud database. 我的讲师建议我使用云数据库。 So first data is send from the GPRS to the Cloud database and then the software which I'm developing get these data from this cloud db and saving it to a local database and then using these data for further use. 因此,首先将数据从GPRS发送到Cloud数据库,然后我正在开发的软件从该Cloud db获取这些数据并将其保存到本地数据库,然后将这些数据用于进一步使用。 Is there any other method to do implement this? 还有其他方法可以实现吗?

I would not recommend a cloud database. 我不建议使用云数据库。 It's not a good pratice have your client application (GPRS module + some microcontroller or microchip) connecting direct to your database (for safety and performance resons). 将客户端应用程序(GPRS模块+一些微控制器或微芯片)直接连接到数据库(出于安全和性能考虑)不是一个好习惯。 You should use webservice (client / server protocols such as HTTP). 您应该使用网络服务(客户端/服务器协议,例如HTTP)。 A very easy way to do it is use PHP + MySQL, you can find really cheap "webpage" servers for like $5/month and they are ready to go. 一个非常简单的方法是使用PHP + MySQL,您可以找到非常便宜的“网页”服务器,每月只需$ 5,即可开始使用。 In your client (GPRS module) you can send somethink like: 在您的客户端(GPRS模块)中,您可以发送如下信息:

GET /v1/methodXXX/?data1=dataHere&data2=MoreData HTTP/1.0
Host: yourwebsitedomain.com

And in your php v1/methodXXX page: 并在您的php v1 / methodXXX页面中:

<?php
  $dbh = new PDO('mysql:host=xxx;port=xxx;dbname=xxx', 'xxx', 'xxx');

    $stmt = $dbh->prepare("INSERT INTO TABLEHERE (id, data1, data2) VALUES (NULL, :data1, :data2)");

    $stmt ->bindValue(':data1', $_GET['data1']);
    $stmt ->bindValue(':data2', $_GET['data2']);

    $stmt->execute();

?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM