当前位置:网站首页>Django -- MySQL database reflects the mapping data model to models
Django -- MySQL database reflects the mapping data model to models
2022-06-28 11:47:00 【weixin_ forty-three million eight hundred and twenty thousand a】
Because just use models To define a table is too much trouble
This article is mainly about mysql Create a table in and then directly in models Generate code in
step1:
stay mysql Create a table

step2:
stay cmd Input in python manage.py inspectdb>polls/models.py among polls Created for you app name
step3:
Click on models.py That is, the generation is complete
Attached separately models The code written in maps to MySQL The method in
step1:
Enter the name of the table you want to create
class StudentInfo(models.Model):
stu_id = models.CharField(primary_key=True, max_length=20)
stu_name = models.CharField(max_length=20)
stu_psw = models.CharField(max_length=20)
step2:
cmd Input in python manage.py makemigrations polls(polls For you app name )
The successful result is shown in the figure

step3:
cmd Input in python manage.py migrate
Refresh MySQL In the table
The addition is complete
边栏推荐
- Join hands with cigent: group alliance introduces advanced network security protection features for SSD master firmware
- Xshell and xftp tutorial
- Use logrotate to automatically cut the website logs of the pagoda
- 近况
- Fruit FL studio/cubase/studio one music host software comparison
- 零基础自学SQL课程 | IF函数
- 一套十万级TPS的IM综合消息系统的架构实践与思考
- Database Series: is there any way to seamlessly upgrade the business tables of the database
- SQL必需掌握的100个重要知识点:检索数据
- day39 原型链及页面烟花效果 2021.10.13
猜你喜欢

Redis6 一:Nosql引入、Redis可以解决什么问题?

day37 js笔记 运动函数 2021.10.11

Deployment and optimization of vsftpd service

人人都可以参与开源!龙蜥社区最不容错过的开发者活动来了

Fruit FL studio/cubase/studio one music host software comparison

day36 js笔记 ECMA6语法 2021.10.09

ThreadLocal的简单理解

科研丨Web of Science检索技巧

Practice and Thinking on the architecture of a set of 100000 TPS im integrated message system

Day31 JS notes DOM 2021.09.26
随机推荐
面试步骤的面试技巧
This Exception was thrown from a job compiled with Burst, which has limited exception support. report errors
Contract quantitative trading system development | contract quantitative app development (ready-made cases)
Graduated
Create ECS using API shortcut
MySQL cannot query the maximum value using the max function
Unity屏幕截图功能
day31 js笔记 DOM下 2021.09.26
Packaging and publishing application of jetpack compose desktop version
Making and using of static library
[sword finger offer] 49 Ugly number
Web page tips this site is unsafe solution
使用logrotate对宝塔的网站日志进行自动切割
董宇辉,新东方以及凤凰卫视
[sciter]: use of sciter FS module scanning file API and its details
携手Cigent:群联为SSD主控固件引入高级网络安全防护特性
MySql5.7添加新用户
It is safer for individuals to choose which securities company to open an account for buying floor funds
[no title] the virtual machine vmnet0 cannot be found and an error is reported: there is no un bridged host network adapter
Fancy features and cheap prices! What is the true strength of Changan's new SUV?