SFTP connection¶
Bases: FileConnection, RenameDirMixin
SFTP file connection. |support_hooks|
Based on Paramiko library <https://pypi.org/project/paramiko/>_.
.. warning::
Since onETL v0.7.0 to use SFTP connector you should install package as follows:
.. code:: bash
pip install "onetl[s3]"
# or
pip install "onetl[files]"
See :ref:`install-files` installation instruction for more details.
.. versionadded:: 0.1.0
Parameters:
-
host(str) –Host of SFTP source. For example:
192.168.1.19 -
port(int, default:`22`) –Port of SFTP source
-
user(str) –User, which have access to the file source. For example:
someuser -
password(str, default:`None`) –Password for file source connection
-
key_file(str, default:`None`) –the filename of optional private key(s) and/or certs to try for authentication
-
timeout(int, default:`10`) –How long to wait for the server to send data before giving up
-
host_key_check(bool, default:`False`) –set to True to enable searching for discoverable private key files in
~/.ssh/ -
compress(bool, default:`True`) –Set to True to turn on compression
Examples:
Create and check SFTP connection:
.. code:: python
from onetl.connection import SFTP
sftp = SFTP(
host="192.168.1.19",
user="someuser",
password="*****",
).check()
path_exists(path)
¶
Check if specified path exists on remote filesystem. |support_hooks|.
.. versionadded:: 0.8.0
Parameters:
-
path(str | :obj:os.PathLike) –Path to check
Returns:
-
``True`` if path exists, ``False`` otherwise–
Examples:
>>> connection.path_exists("/path/to/file.csv")
True
>>> connection.path_exists("/path/to/dir")
True
>>> connection.path_exists("/path/to/missing")
False