简体   繁体   English

以编程方式从谷歌云存储桶下载文件

[英]Programatically download file from google cloud storage bucket

I'm trying to figure out how to download a file from google cloud storage bucket.我想弄清楚如何从谷歌云存储桶下载文件。

My use-case is to run a scheduled script which downloads a .csv file once a day and save it to a SQL DB.我的用例是运行一个计划脚本,该脚本每天下载一个 .csv 文件并将其保存到 SQL 数据库中。

I considered doing it using python and the google SDK but got lost with all the options and which one is the right for me.我考虑过使用 python 和 google SDK 来做,但对所有选项都迷失了,哪一个适合我。

Could someone can explain the difference between cloud storage client, boto, gsutil, and google cloud SDK?有人能解释一下云存储客户端、boto、gsutil 和谷歌云 SDK 之间的区别吗?

Thanks!谢谢!

看看 gcs-fuse:这样就容易多了,因为这样您就可以将 GCS 用作标准文件系统。

The Google Cloud SDK includes a gsutil program. Google Cloud SDK 包含一个gsutil程序。 It is based on the boto Python library.它基于boto Python 库。 "Cloud storage client" is not a specific thing as far as I'm aware.据我所知,“云存储客户端”并不是一个特定的东西。

If you have some kind of scheduler like cron that can regularly run a command, all you need is如果你有像cron这样可以定期运行命令的调度程序,你只需要

gsutil cp gs://mybucket/somefile.csv /tmp/

How to load that into a SQL DB is a separate problem.如何将其加载到 SQL DB 是一个单独的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM