Open aguinane opened 1 year ago
When creating a new table, it would be good to have an option to set unique columns similar to how not_null is set.
from sqlite_utils import Database columns = {"mRID": str, "name": str} db = Database("example.db") db["ExampleTable"].create(columns, pk="mRID", not_null=["mRID"], if_not_exists=True) db["ExampleTable"].create_index(["mRID"], unique=True, if_not_exists=True)
So something like this would add the UNIQUE flag to the table definition.
db["ExampleTable"].create(columns, pk="mRID", not_null=["mRID"], unique=["mRID"], if_not_exists=True)
CREATE TABLE ExampleTable ( mRID TEXT PRIMARY KEY NOT NULL UNIQUE, name TEXT );
When creating a new table, it would be good to have an option to set unique columns similar to how not_null is set.
So something like this would add the UNIQUE flag to the table definition.