Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StopIteration error thrown on empty tables #18

Closed
simonw opened this issue Aug 3, 2019 · 1 comment
Closed

StopIteration error thrown on empty tables #18

simonw opened this issue Aug 3, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@simonw
Copy link
Owner

simonw commented Aug 3, 2019

(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.

@simonw simonw added the bug Something isn't working label Aug 3, 2019
simonw added a commit that referenced this issue Aug 3, 2019
@simonw
Copy link
Owner Author

simonw commented Aug 3, 2019

Leaving this open to remind me to add a unit test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant