官术网_书友最值得收藏!

Understanding the table generated by Django

The toys_toy table persists in the database the Toy class we recently created, specifically, the Toy model. Django's integrated ORM generated the toys_toy table based on our Toy model.

Run the following command to retrieve the SQL used to create the toys_toy table:

    sqlite3 db.sqlite3 ".schema toys_toy"

The following lines show the output for the previous command together with the SQL that the migrations process executed, to create the toys_toy table that persists the Toy model. The next lines are formatted to make it easier to understand the SQL code. Notice that the output from the command is formatted in a different way:

    CREATE TABLE IF NOT EXISTS "toys_toy" 
    (
        "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
        "created" datetime NOT NULL, 
        "name" varchar(150) NOT NULL, 
        "description" varchar(250) NOT NULL, 
        "toy_category" varchar(200) NOT NULL, 
        "release_date" datetime NOT NULL, 
        "was_included_in_home" bool NOT NULL
    );
  

The toys_toy table has the following columns (also known as fields) with their SQLite types, all of them not nullable:

  • id: The integer primary key, an autoincrement row
  • created: DateTime
  • name: varchar(150)
  • description: varchar(250)
  • toy_category: varchar(200)
  • release_date: DateTime
  • was_included_in_home: bool
主站蜘蛛池模板: 裕民县| 乌兰浩特市| 南阳市| 聂荣县| 绥棱县| 安乡县| 井陉县| 盖州市| 同心县| 阿城市| 宣城市| 岑溪市| 安康市| 青岛市| 库伦旗| 西华县| 措勤县| 平定县| 绍兴县| 景泰县| 房山区| 色达县| 阳西县| 延吉市| 鹰潭市| 永城市| 巴南区| 札达县| 阿勒泰市| 镇坪县| 德江县| 望江县| 云梦县| 龙南县| 阜宁县| 泰兴市| 永兴县| 海丰县| 中宁县| 秦皇岛市| 昌黎县|