【Python-Django】医疗辅助平台-数据库设计-day2.1
阿里云国内75折 回扣 微信号:monov8 |
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6 |
操作需知
MySQL存储很长500的汉字选用字符类型_mysql字符串太长用什么存_信息时代弄潮儿的博客-CSDN博客
mysql中的Varchar(255)可以放多少个汉字_Ecloss的博客-CSDN博客_varchar255能存多少汉字
MySQL中的Text类型_SlowIsFastLemon的博客-CSDN博客_text类型
创建病例表(case):
添加示例病症
……
去这个网站下载mysql连接插件
https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient
下载对应的python版本
然后将文件拷贝到项目文件夹
添加到环境中
使用Django连接现已经存在的mysql数据库中的表
参考如何使用Django连接现已经存在的mysql数据库中的表 - 百度文库
在init.py中写如下代码
import pymysql
pymysql.install_as_MySQLdb()
在终端输入
python manage.py inspectdb
即可获取到对应数据库中的表的代码
将此复制粘贴到models.py中:
from django.db import models
class Case(models.Model):
name = models.CharField(primary_key=True, max_length=255)
othername = models.CharField(max_length=255, blank=True, null=True)
introduction = models.TextField(blank=True, null=True)
symptom = models.TextField(blank=True, null=True)
field_insurance = models.CharField(db_column=' insurance', max_length=20, blank=True, null=True) # Field renamed to remove unsuitable characters. Field renamed because it started with '_'.
department = models.CharField(max_length=255, blank=True, null=True)
infection = models.CharField(max_length=20, blank=True, null=True)
position = models.CharField(max_length=255, blank=True, null=True)
period = models.CharField(max_length=255, blank=True, null=True)
crowd = models.CharField(max_length=255, blank=True, null=True)
drug = models.TextField(blank=True, null=True)
method = models.TextField(blank=True, null=True)
class Meta:
managed = False
db_table = 'case'