2

Python 3.7.4 Idle 3.7 32-bit

I am attempting to connect to an SFTP and download a .CSV file to a local network drive. When I run my code, I get no error message, but nothing prints in the shell and nothing is being downloaded to my local directory.

import pysftp
import time


def SFTP_Get_File():
    cnopts = pysftp.CnOpts()
    cnopts.hostkeys = None
    host='ServerName'
    user='FakeUser'
    pw='FakePassword'

    with pysftp.Connection(host,
                           username=user,
                           password=pw,
                           cnopts = cnopts
                           ) as sftp:
        print("Connection succesfully stablished ... ")
        sftp.get('/upload/File_Name.csv', r'Local_File_Name.csv')

    time.sleep(2)
    sftp.close()

Expected Results is I get a print of connection success and the file in the SFTP downloads to my local directory.

Actual Results. Nothing happens.

cccnrc
  • 1,195
  • 11
  • 27
BigZA86
  • 113
  • 1
  • 6

1 Answers1

0

It looks like you are defining the function SFTP_Get_File but you are not calling it.

Try adding

SFTP_Get_File()

to the bottom of your script and running it.

greg_diesel
  • 2,955
  • 1
  • 15
  • 24