Upload text file to rental server by ftp

Since I was able to save the temperature and humidity data in a text file with Raspberry Pi, This time I tried to see if I could upload it to a rental server on a regular basis.

By the way, the rental server I tried was It was "Star Server Free". I was able to upload without any problems.

import ftplib
def ftp_upload(filename):
  ftp = ftplib.FTP('Server hostname')
  ftp.set_pasv('true')
  ftp.login('username','password')
  ftp.cwd('/rp/')
  f = open(filename,'rb')
  ftp.storbinary('STOR ' + filename, f)
  f.close()

ftp_upload('data.txt')

Text data that accumulates at regular intervals, such as temperature and humidity data, is Should I manage it with MySQL instead of a text file?

Recommended Posts

Upload text file to rental server by ftp
Upload & download wav file to X server (X-Server) by FTP with Python
[Python] I will upload the FTP to the FTP server.
Convert HTML to text file
Upload a file to Dropbox
File upload to Azure Storage (Python)
[Python] Continued-Convert PDF text to CSV page by page
Upload the image downloaded by requests directly to S3
Convert a text file with hexadecimal values to a binary file
[Python] Convert PDF text to CSV page by page (2/24 postscript)
Read the xml file by referring to the Python tutorial
[Python] Change standard input from keyboard to text file
How to read text by standard input or file name specification like cat in Python