码迷,mamicode.com
首页 > 数据库 > 详细

python django中如何配置mysql参数

时间:2015-03-31 20:27:53      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:django mysql

在成功安装python-mysql后,开始配置django的mysql连接配置

vi settings.py

修改

DATABASES = {
    ‘default‘: {
        ‘ENGINE‘: ‘django.db.backends.sqlite3‘,
        ‘NAME‘: os.path.join(BASE_DIR, ‘db.sqlite3‘),
    }
}

DATABASES = {
    ‘default‘:{
        ‘ENGINE‘:‘django.db.backends.mysql‘,
        ‘NAME‘:‘cc‘,
        ‘USER‘:‘cc‘,
        ‘PASSWORD‘:‘cc123456‘,
        ‘HOST‘:‘localhost‘,
        ‘PORT‘:‘3306‘,
    }
}

然后

python manage.py dbshell

例:

[root@test cc]# python manage.py dbshell
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 194
Server version: 5.5.36-log Source distribution

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql>

在cc项目下建立books app

python manage.py startapp books

 

python django中如何配置mysql参数

标签:django mysql

原文地址:http://csy520.blog.51cto.com/2896920/1626810

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!