Develop/FastAPI
FastAPI Mysql Create Database Tables - 61
김잠봉
2023. 1. 15. 22:54
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