Closed simonw closed 1 year ago
Demo:
>>> from sqlite_utils import Database
>>> db = Database(memory=True)
>>> db["foo"].insert({"name": "Cleo"})
<Table foo (name)>
>>> print(db["foo"].schema)
CREATE TABLE [foo] (
[name] TEXT
)
>>> db["foo"].transform(not_null={"name"})
<Table foo (name)>
>>> print(db["foo"].schema)
CREATE TABLE "foo" (
[name] TEXT NOT NULL
)
>>> db["foo"].transform(types={"name": int}, keep_table="kept")
<Table foo (name)>
>>> print(db.schema)
CREATE TABLE "kept" (
[name] TEXT NOT NULL
);
CREATE TABLE "foo" (
[name] INTEGER NOT NULL
);
Originally posted by @simonw in https://github.com/simonw/sqlite-utils/issues/565#issuecomment-1646657324