I have seen many people talk about copying a file from a remote server to their local drive but I would like to copy a file from the remote server to another folder on the remote server or to my shared drive.
I am trying to develop a Python GUI to migrate databases in Windows and I would like to be able to copy some of the databases to different locations.
I have tried shutil, xcopy and scp but none of these work. I always get errors like the "path does not exist" or "invalid drive specification".
Basically, I connect to the remote server using pyodbc in the following form:
connection = pyodbc.connect("DRIVER={SQL Server Native Client 10.0};SERVER=@servername;DATABASE=stage;UID=@myuserid;Trusted_Connection=yes").
Once I have connected to server I define the two file paths as variables and then I call the xcopy function:
os.system ("""xcopy "%s" "%s" """ % (copy_path, paste_path)).
Of course I do all of this after importing pyodbc, os, and sys libraries into python. The file does not copy whether I try to paste to a folder on the same server I connect to or my shared drive.
The xcopy only works when I try to copy files from my local to a remote server or vice versa. What I want to know is whether it is possible to copy a file from one spot on my remote server to another using Python.
For example if I remote connect to my remote server and run an xcopy on the following path on the server xcopy "F:\backup\dev\audit.bak" "F:\backup\test" I get the error "invalid drive specification 0 Files copied". I look at the directory tree but the moment I try a backup or a copy it gives me an error.