Tentaclio

1.4.1 ยท active ยท verified Sat Apr 11

Tentaclio is a Python library designed to unify data connectors for distributed data tasks, offering a consistent API for interacting with various data sources like local files, FTP, SFTP, S3, GCS, and databases. It provides a simple URL-based interface for streams and database connections. The library is actively maintained with frequent minor releases to address security updates and improve functionality.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `tentaclio.open` to write and read from a local file. It also includes commented-out code showing how to interact with cloud storage like S3, highlighting Tentaclio's 'automagic authentication' feature via environment variables (e.g., `TENTACLIO__CONN__PREFIX`). For S3 and other cloud protocols, ensure the corresponding optional dependencies are installed.

import tentaclio
import os

# Example: Write and then read a local file
local_file_url = 'file:///tmp/my_data.txt'
contents_to_write = 'Hello, Tentaclio! ๐Ÿ‘‹๐Ÿ™'

# Write to a local file
with tentaclio.open(local_file_url, mode='w') as writer:
    writer.write(contents_to_write)
print(f"Written to {local_file_url}")

# Read from the local file
with tentaclio.open(local_file_url, mode='r') as reader:
    read_contents = reader.read()
print(f"Read from {local_file_url}: {read_contents}")

# Clean up the test file
os.remove('/tmp/my_data.txt')
print("Cleaned up /tmp/my_data.txt")

# Example: Reading from an S3 bucket (requires tentaclio[s3] and AWS credentials)
# Set environment variables like:
# os.environ['TENTACLIO__CONN__MY_S3_BUCKET'] = 's3://access_key:secret_key@s3.region.amazonaws.com/my-bucket/'
# s3_url = 's3://my-bucket/hello.txt'
# if os.environ.get('TENTACLIO__CONN__MY_S3_BUCKET'):
#     try:
#         with tentaclio.open(s3_url) as reader:
#             s3_contents = reader.read()
#         print(f"Read from S3: {s3_contents}")
#     except Exception as e:
#         print(f"Could not read from S3: {e}")

view raw JSON โ†’