简体   繁体   English

将数据从Raspberry Pi传输到在线服务器

[英]Transfer data from Raspberry Pi to Online Server

I'm relatively new to using Raspberry Pi's and Web Servers, but I'm working on a project where I want to read an ID number off a RFID card using a scanner and transfer that ID number to an online web server that contains a SQL database using a Raspberry Pi. 我是使用Raspberry Pi和Web服务器的新手,但是我正在一个项目中,我想使用扫描仪从RFID卡上读取ID号并将该ID号传输到包含SQL的在线Web服务器上Raspberry Pi的数据库。

What is the best way to transfer the ID number from the Raspberry Pi to the online server? 将ID号从Raspberry Pi传输到在线服务器的最佳方法是什么?

I've looked online and most articles talk about creating a web server on the Pi, but is that necessary? 我在网上看过,大多数文章都谈论在Pi上创建Web服务器,但这有必要吗? Is there any way just to send a string or CSV file straight from the Pi to the SQL database on the online server? 有什么方法可以直接从Pi发送字符串或CSV文件到在线服务器上的SQL数据库吗? If so how would I go about doing this? 如果是这样,我将如何去做?

Thanks 谢谢

You've got two ways to achieve it: 您有两种方法可以实现它:

  1. Connect directly to database server using whatever language you want to (eg. php, bash) and then insert ID to your table. 使用您想要使用的任何语言(例如php,bash)直接连接到数据库服务器,然后将ID插入表中。

  2. Create WebService on your remote server and send ID from Raspberry Pi to that WebService. 在远程服务器上创建WebService并将ID从Raspberry Pi发送到该WebService。 Then WS will connect to database and insert it. 然后,WS将连接到数据库并将其插入。

Second way is better because you've more control over it (eg. you can validate that ID or change database structure without changing Raspberry Pi application). 第二种方法更好,因为您可以更好地控制它(例如,您可以在不更改Raspberry Pi应用程序的情况下验证ID或更改数据库结构)。 In both cases you don't need web server on Raspberry Pi side. 在这两种情况下,您都不需要Raspberry Pi上的Web服务器。

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

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