Skip to content

Tynab/boto-3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Boto 3

Repo này minh họa hai tác vụ AWS S3 bằng Python:

  • s3_select.py: dùng S3 Select để lọc dữ liệu CSV trực tiếp trên S3.
  • presign_s3.py: tạo presigned POST và upload file local lên S3.

Cài đặt

py -m pip install -r requirements.txt

Cấu hình

Các script dùng credential AWS mặc định của boto3, ví dụ biến môi trường, AWS profile, hoặc IAM role. Có thể tùy chỉnh runtime bằng các biến sau:

Biến môi trường Mặc định Ý nghĩa
S3_BUCKET nguyendangtruongan.com Bucket S3 cần thao tác
S3_FILE_KEY students.csv Object key trong bucket
S3_SQL_EXPRESSION SELECT s.name, s.email FROM s3object s Câu SQL cho S3 Select
S3_UPLOAD_PATH Giá trị của S3_FILE_KEY File local dùng để upload
S3_EXPIRES_IN 604800 Thời hạn presigned POST, tối đa 7 ngày

Chạy ví dụ

py s3_select.py
py presign_s3.py

students.csv là dữ liệu mẫu có header khớp với câu truy vấn mặc định.

Sponsor this project

  •  

Contributors

Languages