Skip to content

FTP connection

Bases: FileConnection, RenameDirMixin

FTP file connection. support hooks

Based on FTPUtil library.

Warning

Since onETL v0.7.0 to use FTP connector you should install package as follows:

pip install "onetl[ftp]"

# or
pip install "onetl[files]"
See File connections install installation instruction for more details.

Added in 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.

    None means that the user is anonymous.

  • password (str, default: None ) –

    Password for file source connection.

    None means that the user is anonymous.

Examples:

Create and check FTP connection:

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.

Added in 0.8.0

Parameters:

  • path (str | PathLike) –

    Path to check

Returns:

  • bool

    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