djang create a database

django connected database
1. need to modify the configuration file
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'day54',
'the HOST': '127.0.0.1',
' PORT ': 3306,
' the USER ':' root ',
' PASSWORD ':' 123 '
}
}
PS: key must be in all uppercase

2. tell django replace it with pymysql mysqldb default database module connection
mode 1: in your project file the following clip __init__.py
mode 2: you can also use folders in your __init__.py following

fixed wording
Import pymysql
pymysql.install_as_MySQLdb () # tell django with pymysql connect to the database instead of mysqldb

What is ORM?
Relational Mapping Object
Class "" "Table
" "object" table record
attribute "object", "a field value corresponding to a record

The django orm can not automatically help you create a library, but can help you automatically create a table

Tip: a django project on the use of a library, do not use a multiple django project library

 

Database Migration (synchronous) command (******)
python3 manage.py makemigrations your database changes on a small notebook to record (and will not help you create a table)
python3 manage.py the migrate your database changes are synchronize to the database

Guess you like

Origin www.cnblogs.com/qingqinxu/p/11238661.html