Skip to content

Document that running db.transform() tidies up the schema indentation #564

@simonw

Description

@simonw

... and it turns out running .transform() with no arguments still fixes the format of the schema!

>>> db["log"].add_column("foo", str)
<Table log (id, name2, age, weight, foo)>
>>> db["log"].add_column("bar", str)
<Table log (id, name2, age, weight, foo, bar)>
>>> db["log"].add_column("baz", str)
<Table log (id, name2, age, weight, foo, bar, baz)>
>>> print(db["log"].schema)
CREATE TABLE "log" (
   [id] INTEGER PRIMARY KEY,
   [name2] TEXT,
   [age] INTEGER,
   [weight] FLOAT
, [foo] TEXT, [bar] TEXT, [baz] TEXT)
>>> db["log"].transform()
<Table log (id, name2, age, weight, foo, bar, baz)>
>>> print(db["log"].schema)
CREATE TABLE "log" (
   [id] INTEGER PRIMARY KEY,
   [name2] TEXT,
   [age] INTEGER,
   [weight] FLOAT,
   [foo] TEXT,
   [bar] TEXT,
   [baz] TEXT
)

Originally posted by @simonw in simonw/llm#65 (comment)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions