Skip to content

load should handle case where database tables already exist #6

Closed

Description

@simonw
% sqlite-diffable load simonwillisonblog.db simonwillisonblog
Traceback (most recent call last):
  File "/Users/simon/.local/share/virtualenvs/sqlite-diffable-J1UjzcIN/bin/sqlite-diffable", line 33, in <module>
    sys.exit(load_entry_point('sqlite-diffable', 'console_scripts', 'sqlite-diffable')())
  File "/Users/simon/.local/share/virtualenvs/sqlite-diffable-J1UjzcIN/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/simon/.local/share/virtualenvs/sqlite-diffable-J1UjzcIN/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/simon/.local/share/virtualenvs/sqlite-diffable-J1UjzcIN/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/simon/.local/share/virtualenvs/sqlite-diffable-J1UjzcIN/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/simon/.local/share/virtualenvs/sqlite-diffable-J1UjzcIN/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/simon/Dropbox/Development/sqlite-diffable/sqlite_diffable/cli.py", line 90, in load
    db.execute(schema)
  File "/Users/simon/.local/share/virtualenvs/sqlite-diffable-J1UjzcIN/lib/python3.10/site-packages/sqlite_utils/db.py", line 465, in execute
    return self.conn.execute(sql)
sqlite3.OperationalError: table "blog_entry" already exists

That error should be neater - but there should also be options for running this against a previously created database.

Activity

  1. simonw commented on Jul 11, 2022

    @simonw
    OwnerAuthor

    I'm going to add a --replace option which drops and replaces any tables that already exist.

  2. simonw commented on Jul 11, 2022

    @simonw
    OwnerAuthor

    I want to be able to run this in conjunction with sqlite-comprehend which adds its own tables - I don't want those tables to be deleted when I update the other tables using this tool.

  3. added a commit that references this issue on Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions