sae服务器数据库配置流程
1,配置数据库:在setting.py,删掉原来的默认sqlite配置,使用如下配置
# online database settings MYSQL_HOST = 'w.rdc.sae.sina.com.cn' MYSQL_PORT = '3307' MYSQL_USER = 'accesskey'#可以从sae项目中查找到 MYSQL_PASS = 'secretkey'#可以从sae项目中查找到 MYSQL_DB = 'app_appName'#自己取项目名字 import sae from sae._restful_mysql import monkey monkey.patch() DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': MYSQL_DB, 'USER': MYSQL_USER, 'PASSWORD': MYSQL_PASS, 'HOST': MYSQL_HOST, 'PORT': MYSQL_PORT, } }
2,在sae网站上初始化项目的mysql服务
3,本地安装sae-python-dev: sudo pip install sae-python-dev
4,执行python manage.py syncdb就可以同步数据到远程数据库了
5,本地代码提交到svn上的时候,需要把settings.py里面配置注释掉,需要注释的代码如下:
import sae from sae._restful_mysql import monkey monkey.patch()