本文写的是python Django连接MySQL数据库的步骤,提供增删改查的代码
1、下载安装MySQLdb类库
http://www.djangoproject.com/r/python-mysql/
2、修改settings.py 配置数据属性
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'djangodb', # Or path to database file if using sqlite3.
# The following settings are not used with sqlite3:
'USER': 'root',
'PASSWORD': 'root',
'HOST': '127.0.0.1', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
'PORT':