Skip to content

StopIteration error thrown on empty tables #18

@simonw

Description

@simonw
(db-to-sqlite) bash-3.2$ python -i $(which db-to-sqlite) postgresql://localhost:5433/db --all db.db
Traceback (most recent call last):
  File "/Users/simonw/.local/share/virtualenvs/db-to-sqlite-CRf3fZQ-/bin/db-to-sqlite", line 11, in <module>
    load_entry_point('db-to-sqlite', 'console_scripts', 'db-to-sqlite')()
  File "/Users/simonw/.local/share/virtualenvs/db-to-sqlite-CRf3fZQ-/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/Users/simonw/.local/share/virtualenvs/db-to-sqlite-CRf3fZQ-/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/Users/simonw/.local/share/virtualenvs/db-to-sqlite-CRf3fZQ-/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/simonw/.local/share/virtualenvs/db-to-sqlite-CRf3fZQ-/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/Users/simonw/Desktop/Development/db-to-sqlite/db_to_sqlite/cli.py", line 103, in cli
    db[table].upsert_all(rows, pk=pk)
  File "/Users/simonw/.local/share/virtualenvs/db-to-sqlite-CRf3fZQ-/lib/python3.6/site-packages/sqlite_utils/db.py", line 1018, in upsert_all
    extracts=extracts,
  File "/Users/simonw/.local/share/virtualenvs/db-to-sqlite-CRf3fZQ-/lib/python3.6/site-packages/sqlite_utils/db.py", line 885, in insert_all
    first_record = next(records)
StopIteration

This is actually due to sqlite_utils being unable to handle empty lists passed to upsert_all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions