【发布时间】:2019-07-08 01:13:42
【问题描述】:
我想将 pandas 数据框的内容插入到 Google Cloud Spanner 数据库中的表中。文档here 建议使用批处理对象的insert_or_update() 方法。
如果批处理对象是通过运行这个来创建的
from google.cloud import spanner_v1
client = spanner_v1.Client()
batch = client.batch()
那么这个对象没有那个方法可用。运行 dir(client) 会给我这些结果
['SCOPE',
'_SET_PROJECT',
'__class__',
'__delattr__',
'__dict__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__getstate__',
'__gt__',
'__hash__',
'__init__',
'__init_subclass__',
'__le__',
'__lt__',
'__module__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__setattr__',
'__sizeof__',
'__str__',
'__subclasshook__',
'__weakref__',
'_credentials',
'_database_admin_api',
'_determine_default',
'_http',
'_http_internal',
'_instance_admin_api',
'_item_to_instance',
'copy',
'credentials',
'database_admin_api',
'from_service_account_json',
'instance',
'instance_admin_api',
'list_instance_configs',
'list_instances',
'project',
'project_name',
'user_agent']
如何在 Spanner 中进行批量更新插入?
【问题讨论】:
标签: python-3.x google-cloud-platform google-cloud-functions google-cloud-spanner