Discuss / Python / 请问github上的示例代码schema.sql中最后一行是什么意思?

请问github上的示例代码schema.sql中最后一行是什么意思?

Topic source

我看的是2.7教程的示例代码

-- init database

drop database if exists awesome;

create database awesome;

use awesome;

grant select, insert, update, delete on awesome.* to 'www-data'@'localhost' identified by 'www-data';

create table users (
    `id` varchar(50) not null,
    `email` varchar(50) not null,
    `password` varchar(50) not null,
    `admin` bool not null,
    `name` varchar(50) not null,
    `image` varchar(500) not null,
    `created_at` real not null,
    unique key `idx_email` (`email`),
    key `idx_created_at` (`created_at`),
    primary key (`id`)
) engine=innodb default charset=utf8;

create table blogs (
    `id` varchar(50) not null,
    `user_id` varchar(50) not null,
    `user_name` varchar(50) not null,
    `user_image` varchar(500) not null,
    `name` varchar(50) not null,
    `summary` varchar(200) not null,
    `content` mediumtext not null,
    `created_at` real not null,
    key `idx_created_at` (`created_at`),
    primary key (`id`)
) engine=innodb default charset=utf8;

create table comments (
    `id` varchar(50) not null,
    `blog_id` varchar(50) not null,
    `user_id` varchar(50) not null,
    `user_name` varchar(50) not null,
    `user_image` varchar(500) not null,
    `content` mediumtext not null,
    `created_at` real not null,
    key `idx_created_at` (`created_at`),
    primary key (`id`)
) engine=innodb default charset=utf8;

-- email / password:
-- admin@example.com / password

insert into users (`id`, `email`, `password`, `admin`, `name`, `created_at`) values ('0010018336417540987fff4508f43fbaed718e263442526000', 'admin@example.com', '5f4dcc3b5aa765d61d8327deb882cf99', 1, 'Administrator', 1402909113.628);

与课程里相比多出来的这个“insert into ...”这一行什么意思

那个uers表的id值看起来是自动生成的,那么到底最后那三行是不是也要写到sql脚本里去运行?

我现在明白的部分: 两“--”表示注释,因为只创建一个管理员用户,符合教程里说的表比较少的例子所以直接手工写在sql脚本里,不另外通过model对象生成。 我现在还不明白的部分: insert的这行数据,id对应的值和 password对应的值这两个乱码,是我写脚本时候替换成我自定义的id和密码的意思么?还有create_at对应的值这个也是手写么?(我疑惑的原因是,示例代码这三个值看起来像是自动生成的,按廖老师之前的风格需要自己手写替换的部分都写成“www-date”,所以我有点乱)


  • 1

Reply