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

sqlite-utils create-table command #27

Closed
7 tasks done
simonw opened this issue Jun 13, 2019 · 8 comments
Closed
7 tasks done

sqlite-utils create-table command #27

simonw opened this issue Jun 13, 2019 · 8 comments
Labels
enhancement New feature or request

Comments

@simonw
Copy link
Owner

simonw commented Jun 13, 2019

Spun off from #24 - it would be useful if CLI users could create new tables (with explicit column types, not null rules and defaults) without having to insert an example record.

  • Get it working
  • Support --pk
  • Support --not-null
  • Support --default
  • Support --fk colname othertable othercol
  • Support --replace and --ignore
  • Documentation
@simonw simonw added the enhancement New feature or request label Jun 13, 2019
@simonw
Copy link
Owner Author

simonw commented Aug 31, 2019

Potential syntax:

$ sqlite-utils create-table foo.db dogs \
    id integer \
    name string \
    age integer \
    --pk=id

@simonw
Copy link
Owner Author

simonw commented May 3, 2020

Copy the design for --not-null and --default from the insert command:

$ sqlite-utils insert dogs.db dogs_with_scores dogs-with-scores.json \
    --not-null=age \
    --not-null=name \
    --default age 2 \
    --default score 5

@simonw
Copy link
Owner Author

simonw commented May 3, 2020

Could take --ignore to ignore if table already exists, and --replace to drop and replace it if it exists.

@simonw
Copy link
Owner Author

simonw commented May 3, 2020

I need tests for what happens if table already exists, or if the user provides invalid column types.

@simonw
Copy link
Owner Author

simonw commented May 3, 2020

Supporting --fk colname othertable othercol would be neat too.

@simonw
Copy link
Owner Author

simonw commented May 3, 2020

Be nice if you could do --fk colname and have it guess the rest, but I'm not sure how to do that with a CLI option - they need a fixed number of arguments so that they don't consume the next batch of options.

@simonw
Copy link
Owner Author

simonw commented May 3, 2020

I'll stick with requiring all three fk arguments.

@simonw
Copy link
Owner Author

simonw commented May 3, 2020

@simonw simonw closed this as completed May 3, 2020
simonw added a commit that referenced this issue May 3, 2020
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