simonw / sqlite-utils

Python CLI utility and library for manipulating SQLite databases
https://sqlite-utils.datasette.io
Apache License 2.0
1.58k stars 106 forks source link

create-table command does not handle compound primary keys #620

Closed simonw closed 4 months ago

simonw commented 4 months ago

I tried running this:

sqlite-utils create-table compound.db compound \
  category text id integer value text --pk category --pk id

And got this schema:

CREATE TABLE [compound] (
   [category] TEXT,
   [id] INTEGER PRIMARY KEY,
   [value] TEXT
);
simonw commented 4 months ago

The documentation doesn't indicate that this works, but it should work for consistency with how transform works.

https://sqlite-utils.datasette.io/en/stable/cli.html#cli-create-table

simonw commented 4 months ago

Looking at https://sqlite-utils.datasette.io/en/latest/cli-reference.html there are other commands that should accept multiple primary keys as well:

The transform command accepts multiple --pk already.