가 나는 또한 기본 응용 프로그램을 변경 한 경우 BigQuery 테이블Google 클라우드 BigQuery를 가져 오기
import argparse
import time
import uuid
from google.cloud import bigquery
def load_data_from_gcs(dataset_name, table_name, source):
bigquery_client = bigquery.Client()
dataset = bigquery_client.dataset(dataset_name)
table = dataset.table(table_name)
job_name = str(uuid.uuid4())
job = bigquery_client.load_table_from_storage(
job_name, table, source)
job.begin()
wait_for_job(job)
print('Loaded {} rows into {}:{}.'.format(
job.output_rows, dataset_name, table_name))
def wait_for_job(job):
while True:
job.reload()
if job.state == 'DONE':
if job.error_result:
raise RuntimeError(job.error_result)
return
time.sleep(1)
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('dataset_name')
parser.add_argument('table_name')
parser.add_argument(
'source', help='The Google Cloud Storage object to load. Must be in '
'the format gs://bucket_name/object_name')
args = parser.parse_args()
load_data_from_gcs(
args.dataset_name,
args.table_name,
args.source)
에 구글 클라우드 버킷에서 데이터를 이동하는 앱 엔진 프로젝트를 빌드하려면 다음 코드를 사용하고 응용 프로그램 엔진 프로젝트에서 작동하지 .yaml 위의 파일과 같은 파일은 webapp2 라이브러리 항목을 삭제하고 나는 내가에서 정의하는 라이브러리를 포함해야하는 경우 몰라요 파이썬 앱 엔진에 새로운 오전으로 내 애플리케이션 제목 파일이
application: gcstobq
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: .*
script: main.app
처럼 보인다 main.py 파일을 app.yaml에 넣고이 앱을 실행해야하는 경우 usi 명령 행 도구를 사용하십시오.
내가 여기에 뭔가를 놓친다면 알려주시겠습니까?
오류 : 그냥 파이썬 3 동작을 취득 (다른 수입하기 전에) 파일의 맨 위에이 추가? 직업 ID? –
아직 클라우드에 응용 프로그램을 업로드하지 않았지만 localhost에서 실행할 때 로그 파일에 다음 내용이 표시되지만 큰 쿼리 테이블로 데이터가 전송되지 않았습니다. ImportError : 모듈 이름이 구름이 아닙니다 – LondonUK
Google Python 라이브러리를 설치하셨습니까? 즉, pip install --upgrade google-cloud-bigquery –