FTP connection¶
Bases: FileConnection, RenameDirMixin
FTP file connection. |support_hooks|
Based on FTPUtil library <https://pypi.org/project/ftputil/>_.
.. warning::
Since onETL v0.7.0 to use FTP connector you should install package as follows:
.. code:: bash
pip install "onetl[ftp]"
# or
pip install "onetl[files]"
See :ref:`install-files` installation instruction for more details.
.. versionadded:: 0.1.0
Parameters:
-
host(str) –Host of FTP source. For example:
ftp.domain.com -
port(int, default:`21`) –Port of FTP source
-
user(str, default:`None`) –User, which have access to the file source. For example:
someuser.Nonemeans that the user is anonymous. -
password(str, default:`None`) –Password for file source connection.
Nonemeans that the user is anonymous.
Examples:
Create and check FTP connection:
.. code:: python
from onetl.connection import FTP
ftp = FTP(
host="ftp.domain.com",
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