Answer the question
In order to leave comments, you need to log in
Python FTP how to properly connect to server?
After reading the guides on "ftplib" I decided to connect to the FTP server to work with the database, the problem is that the connection does not work, it hangs at the ftp.connect(HOST, PORT) stage, here is the code:
from ftplib import FTP
HOST = 'server_ip'
PORT = 22
USER = 'root',
PASSWORD = 'my_pass'
ftp = FTP()
print(f'Conecting to FTP\nHost: {HOST}\nPort: {PORT}')
ftp.connect(HOST, PORT)
print(f'Conecting sucess!\nLogin as: {USER},Pass: {PASSWORD}')
ftp.login(USER, PASSWORD)
print('Login Succes!')
Answer the question
In order to leave comments, you need to log in
You connect on port 22, which is usually sftp and not ftp.
wat? Work with a DB through ftp?
You need to work with the database using specialized tools. In this case, a muscle / postgrey / any other subd is raised on the server and a connection goes to them with the help of python modules. For mysql there is pymysql.
Well, if you connect to the database from a remote computer, then you need to configure everything correctly. The Internet is full of guides on this topic.
And about your question - IMHO you are SSZB
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question