将django项目移植到mysql
来源:互联网 发布:qt抽奖软件 编辑:程序博客网 时间:2024/06/10 21:01
django 1.4, mysql5.5, mysql_for_python1.2.1
将已创建好的项目由sqlite3移植到mysql。已创建好的django项目,详见
http://blog.csdn.net/ppdouble/article/details/7718594
http://blog.csdn.net/ppdouble/article/details/7673359
一、首先创建数据库
mysql> CREATE DATABASE tdata_mysql -> CHARACTER SET utf8 -> COLLATE utf8_general_ci;二、修改项目的数据库配置
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'tdata_mysql', # Or path to database file if using sqlite3. 'USER': 'root', # Not used with sqlite3. 'PASSWORD': 'python', # Not used with sqlite3. 'HOST': 'python.centos', # Set to empty string for localhost. Not used with sqlite3. 'PORT': '3306', # Set to empty string for default. Not used with sqlite3. }}
注意:NAME只需使用数据库名,python.centos是我的本地主机名
三、使用python的数据库API创建数据表,进入项目所在目录运行python manage.py syncdb
# python manage.py syncdbCreating tables ...Creating table auth_permissionCreating table auth_group_permissionsCreating table auth_groupCreating table auth_user_user_permissionsCreating table auth_user_groupsCreating table auth_userCreating table django_content_typeCreating table django_sessionCreating table django_siteCreating table tjob_locationCreating table tjob_jobCreating table django_admin_logYou just installed Django's auth system, which means you don't have any superusers defined.Would you like to create one now? (yes/no): yes Username (leave blank to use 'python'): djrootE-mail address: djroot@python.centosPassword: Password (again): Superuser created successfully.Installing custom SQL ...Installing indexes ...Installed 0 object(s) from 0 fixture(s)四、使用python的web管理工具http://127.0.0.1/tdjproj/admin/添加数据后,使用mysql客户端工具登录到数据库查看数据变化
mysql> show tables;+----------------------------+| Tables_in_tdata_mysql |+----------------------------+| auth_group || auth_group_permissions || auth_permission || auth_user || auth_user_groups || auth_user_user_permissions || django_admin_log || django_content_type || django_session || django_site || tjob_job || tjob_location |+----------------------------+12 rows in set (0.00 sec)mysql> select * from tjob_job;+----+------------+-------------+-----------------+-------------+| id | pub_date | job_title | job_description | location_id |+----+------------+-------------+-----------------+-------------+| 1 | 2012-07-16 | SW_engineer | SW_engineer | 1 |+----+------------+-------------+-----------------+-------------+1 row in set (0.00 sec)mysql> select * from tjob_location;+----+------+-------+---------+| id | city | state | country |+----+------+-------+---------+| 1 | NY | NY | US |+----+------+-------+---------+1 row in set (0.00 sec)
- 将django项目移植到mysql
- 将django项目移植到apache
- 将Django项目搭建到服务器上
- 将项目从VSS移植到TFS。
- 将cocos2d-x项目移植到android
- 将 Django 项目从 MySQL 迁移至 PostgreSQL
- 将AVS1-P2 Decoder项目移植到linux下
- 将现有myeclipse项目移植到maven环境下
- 将FB4.5的项目移植到FB3中开发
- 将cocos2d-x项目打包.apk移植到Android
- 将 Linq to SQl 项目移植到 Linq to Oracle
- 【cocos2d-x 3.0】将项目移植到Android【codingnow.cn】
- 将cocos2dx项目从VS移植到Eclipse - CoolJie
- 将eclipse里的项目移植到android studio中
- android 将Android Studio项目移植到Eclipse
- [图文]将cocos2d-x项目移植到android上
- 1.将cocos2d-x项目移植到Linux环境下,将cocos2d-x项目移植到手机上
- 将mysql 移植到oracle ――第二部分
- widget的宽度比例设置
- UML包图
- web.xml配置说明
- QT皮肤(QSS)编程
- 背景图铺满屏幕的方法
- 将django项目移植到mysql
- A Road Map Through Nachos——Nachos machine
- qt 字符串转换 最最详细版本
- 虚拟机网络配置
- 解析Json协议工具
- 如何保持软件开发团队的稳定性
- RedGate Reflector / ANTS memory profiler / ANTS performance profiler 7.5
- 用QT创建新风格
- Oracle Stream Replication - 删除源库归档日志后出现问题