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

Implement sqlite_expand command #8

Open
niconoe opened this issue Nov 10, 2020 · 2 comments
Open

Implement sqlite_expand command #8

niconoe opened this issue Nov 10, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@niconoe
Copy link
Collaborator

niconoe commented Nov 10, 2020

Following discussion with @peterdesmet, it's been decided to create a new command:

$ sqlite_expand db table_name table_schema_path

It takes a sqlite database, a table name and a schema file (example: https://github.com/timrobertson100/frictionless-transforms/blob/master/datasets/periodic_table/transforms/table_schema.json) and:

  • add the missing fields to the database
  • if possible, change the type of the existing fields
  • if possible, reorder fields so working with the database interactively is a bit more friendly
@niconoe niconoe added the enhancement New feature or request label Nov 10, 2020
@niconoe niconoe self-assigned this Nov 10, 2020
@niconoe
Copy link
Collaborator Author

niconoe commented Nov 18, 2020

@peterdesmet: I've done some research about this and it appears that reordering field is not really possible on an existing table. Changing data types/constraints can also be cumbersome. I'm therefore thinking a better way to implement this could be:

  • rename the existing table to table_name__old
  • create a fresh table table_name based on the schema file (with the right field order, extra constraints, ...)
  • copy data from table_name__old to table_name (that might explode in flight if the existing data doesn't fit the field types and constraint defined in the schema). Also warn of data loss if some columns in the original data don't exist in the schema.
  • If all if successful, drop table_name__old

Any opinion about this before I jump to implementation? thanks!

@peterdesmet
Copy link
Collaborator

That sound reasonable

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

2 participants