Skip to content

.insert_all() and .upsert_all() to support iterator of Python lists/tuples #672

@simonw

Description

@simonw

The table.insert_all() and table.upsert_all() methods currently only work with iterators of dictionaries, where each dictionary represents a row and the column names are the keys.

This is inefficient over large number of rows.

How about if they could also accept iterators that look like this?

def rows():
    yield "id", "title", "content"
    for row in some_other_source():
        yield row.id, row.title, row.content

This looks similar to CSV. The first "row" is the column titles, subsequent rows are the row values themselves.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions