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

Ability to create a new table #5

Closed
simonw opened this issue Mar 15, 2020 · 9 comments
Closed

Ability to create a new table #5

simonw opened this issue Mar 15, 2020 · 9 comments
Labels
enhancement New feature or request

Comments

@simonw
Copy link
Owner

simonw commented Mar 15, 2020

No description provided.

@simonw simonw added the enhancement New feature or request label Mar 15, 2020
@simonw
Copy link
Owner Author

simonw commented Mar 15, 2020

This feature will be much more interesting when accompanied by some plugin that supports inserting data into tables.

@simonw
Copy link
Owner Author

simonw commented Jul 6, 2020

Some unfinished code I just removed while working on #8:

async def post(self, request):
    formdata = await request.form()
    database_name = request.url_vars["database"]
    columns = [
        c.split(".", 1)[1] for c in formdata.keys() if c.startswith("column.")
    ]
    table = formdata["table"]
    # TODO: Create table
    raise NotImplementedError

@simonw
Copy link
Owner Author

simonw commented Aug 18, 2023

I'm going to force the user to have a primary key in their table - it will default to id integer primary key but they can change it to a text if they want to (and change the name).

Should I let users have a compound primary key? I think not - if they really want that they can use a create table statement directly, but it feels too confusing to explain to users who are using a visual table builder.

@simonw
Copy link
Owner Author

simonw commented Aug 18, 2023

This feature will be much more interesting when accompanied by some plugin that supports inserting data into tables.

Well that exists now! https://github.com/datasette/datasette-write-ui

@simonw
Copy link
Owner Author

simonw commented Aug 18, 2023

The UI can look like this:

CleanShot 2023-08-17 at 23 18 59@2x

So the primary key column is always at the top and can't be dragged around or deleted, but can have its name and type changed (probably limit type to integer or text though, float feels weird - blob could be OK but I'd rather not go there yet.)

@simonw
Copy link
Owner Author

simonw commented Aug 18, 2023

Actually no need for delete buttons that are checkboxes, they can be real buttons that JavaScript remove that row from the page.

And there needs to be a prominent "add column" button that adds a new row.

@simonw
Copy link
Owner Author

simonw commented Aug 18, 2023

The "table name" form field should fetch() check for tables with the same name and display an error + prevent you from submitting if your table matches an existing table.

@simonw
Copy link
Owner Author

simonw commented Sep 7, 2023

I won't bother with "add another column" just yet, I'll provide ten and people can add more using the edit table screen later if they need to.

@simonw simonw closed this as completed in 6cb3636 Sep 7, 2023
simonw added a commit that referenced this issue Sep 7, 2023
@simonw
Copy link
Owner Author

simonw commented Sep 7, 2023

Demo:

create-demo

simonw added a commit that referenced this issue Sep 9, 2023
simonw added a commit that referenced this issue Sep 9, 2023
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