Chinaunix首页 | 论坛 | 博客
  • 博客访问: 8295704
  • 博文数量: 1413
  • 博客积分: 11128
  • 博客等级: 上将
  • 技术积分: 14685
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-13 10:03
个人简介

follow my heart...

文章分类

全部博文(1413)

文章存档

2013年(1)

2012年(5)

2011年(45)

2010年(176)

2009年(148)

2008年(190)

2007年(293)

2006年(555)

分类:

2008-11-17 01:13:30

我喜欢django,而且我也喜欢postgresql.所以我想把他们结合在一起。好在django里面要使用postgresql数据库很简单。
1.安装需要的库:我是在mandriva2009下做的试验,需要urpmi psycopg,以便这这个库;
2.在postgresql里面建一个数据库,比如说demo;
3.那么对应的数据库的投置可以在django项目的setting文件中更改:
DATABASE_ENGINE = 'postgresql'           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'demo'             # Or path to database file if using sqlite3.
DATABASE_USER = 'postgres'             # Not used with sqlite3.
DATABASE_PASSWORD = ''         # Not used with sqlite3.
DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.
4.因为是在本地做试验,所以host置空了。其它如password,port如果没有修改可置空,当然如有改动,根据实际情况而定了。
5.在django项目目录下,python manager.py syncdb后可以看到数据的同步过程。我觉得postgresql与mysql相比的感觉与freebsd与linux的比较类似,前者侧重于学院派,而后者则相对更易用,但是从安全性及其它特性来讲,前者似乎更加强大。
阅读(2848) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~