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

load should handle case where database tables already exist #6

Closed
simonw opened this issue Jul 11, 2022 · 3 comments
Closed

load should handle case where database tables already exist #6

simonw opened this issue Jul 11, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@simonw
Copy link
Owner

simonw commented Jul 11, 2022

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

@simonw simonw added the enhancement New feature or request label Jul 11, 2022
@simonw
Copy link
Owner Author

simonw commented Jul 11, 2022

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

@simonw
Copy link
Owner Author

simonw commented Jul 11, 2022

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.

@simonw simonw closed this as completed in 7d3cbc3 Jul 11, 2022
@simonw
Copy link
Owner Author

simonw commented Jul 11, 2022

simonw added a commit that referenced this issue Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant