google-cloud-python
google-cloud-python copied to clipboard
Batch commit can be better explained in MutationsBatcher documentation
Environment details
- OS type and version: ChromeOS
- Python version: Python 3.7.3
- pip version: pip 18.1
google-cloud-bigtableversion: 2.4.0
Steps to reproduce
- Read the docs for MutationBatcher. Which states " if it reaches the max number of rows it calls finish_batch() to mutate the current row batch."
- Use finish_batch(rows) or just finish_batch() in your code then observe error
Code example
client = Client(project='my-project-ID', credentials=credentials)
instance = client.instance('instanceName')
table = instance.table('tableName')
batcher = table.mutations_batcher(flush_count=100000)
for files in os.listdir():
if files.startswith('prefix'):
with open(files, newline='') as csvfile:
csvreader = csv.reader(csvfile, delimiter=' ', quotechar='|')
for crow in csvreader:
rows = []
row = table.row(crow[0])
row.set_cell("location", "latitude", crow[1])
row.set_cell("location", "longitude", crow[2])
rows.append(row)
batcher.finish_batch(rows)
Stack trace
Traceback (most recent call last):
File "bigtable.py", line 43, in <module>
batcher.finish_batch(rows)
AttributeError: 'MutationsBatcher' object has no attribute 'finish_batch'
Using batcher.flush() instead works.
Transferring to google-cloud-python as the code for python-bigtable will be migrated there in 1-3 weeks.
This issue is being bulk closed due to inactivity. Please re-open if you think this still requires attention, and we'll take another look. Thanks!