Upload.insert_rows
Upload.insert_rows(rows, *, update_schema=False) → Dict<insertRows response>
Insert rows into the upload. Can only be called on unreleased uploads of type stream. Should be called at most once per second, per upload; for increased performance try batching multiple rows into a single request, up to a limit of 100MB per request.
Parameters:
rows : list<dict<varname, val>>
The rows to insert. A list of dicts, with each dict representing a single row, where the keys are the variable names, and the values are the value for that variable in that row. E.g.,
[{ "var1": 1, "var2": "foo"}, { "var1": None, "var2": "bar" }]
Returns:
Examples
import redivis
dataset = redivis.user("user_name").dataset("dataset_name", version="next")
table = dataset.table("table_name")
# Providing a schema with the initial request is optional (but recommended).
# If not set, schema will be inferred based on the first batch of rows.
schema = [
{ "name": "var1", "type": "string" },
{ "name": "var2", "type": "integer" },
{ "name": "var3", "type": "dateTime" }
]
rows = [
{ "var1": "hello", "var2": 1, "var3": None },
# dateTime must be in the format YYYY-MM-DD[ |T]HH:MM:SS[.ssssss]
{ "var1": "world", "var2": 2, "var3": "2020-01-01T00:00:00.123" }
]
upload = table.upload(name="my_stream")
# Create, or get a reference to an exisiting upload named "my_stream"
upload.create(type="stream", schema=schema, if_not_exists=True)
insert_response = upload.insert_rows(rows)
# See REST API / uploads / insertRows
print(insert_response)Last updated
Was this helpful?

