728x90
1. 스키마 생성
2. 테이블 생성
use todoapp;
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users`(
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(200) DEFAULT NULL,
`username` varchar(45) DEFAULT NULL,
`first_name` varchar(45) DEFAULT NULL,
`last_name` varchar(45) DEFAULT NULL,
`hashed_password` varchar(200) DEFAULT NULL,
`is_active` int(1) DEFAULT NULL,
PRIMARY KEY(`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS `todos`;
CREATE TABLE `todos`(
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(200) DEFAULT NULL,
`description` varchar(200) DEFAULT NULL,
`priority` int(1) DEFAULT NULL,
`complete` int(1) DEFAULT NULL,
`owner_id` int(11) DEFAULT NULL,
PRIMARY KEY(`id`),
FOREIGN KEY(`owner_id`) REFERENCES users(`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
3. 테이블 생성 확인
728x90
SMALL
'Develop > FastAPI' 카테고리의 다른 글
FastAPI Create Data for MySQL - 63 (0) | 2023.01.15 |
---|---|
FastAPI Connect FastAPI to MySQL - 62 (0) | 2023.01.15 |
FastAPI Create Data for PostgreSQL - 60 (0) | 2023.01.15 |
FastAPI PostgreSQL Connect to FastAPI - 59 (0) | 2023.01.15 |
FastAPI PostgreSQL Create Database Table - 58 (0) | 2023.01.15 |