Skip to content

sqlite-utils create-table command #27

Closed

Description

@simonw

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

Activity

  1. simonw commented on Aug 31, 2019

    @simonw
    OwnerAuthor

    Potential syntax:

    $ sqlite-utils create-table foo.db dogs \
        id integer \
        name string \
        age integer \
        --pk=id
    
  2. simonw commented on May 3, 2020

    @simonw
    OwnerAuthor

    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
    
  3. simonw commented on May 3, 2020

    @simonw
    OwnerAuthor

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

  4. simonw commented on May 3, 2020

    @simonw
    OwnerAuthor

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

  5. simonw commented on May 3, 2020

    @simonw
    OwnerAuthor

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

  6. simonw commented on May 3, 2020

    @simonw
    OwnerAuthor

    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.

  7. simonw commented on May 3, 2020

    @simonw
    OwnerAuthor

    I'll stick with requiring all three fk arguments.

  8. added a commit that references this issue on May 3, 2020
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