Catalyst::Manual::Tutorial::10_Appendices
时间:2010-08-30 来源:horsley
也因为如此,我们的目的也不是把数据库的很多个性化的东西发挥到极致,比如对于约束完整性方面的东西。
PostgreSQL
通过下面几步可以将本章例子迁移到 PostgreSQL 数据库。感谢 xxxx .....
- 针对第三章 : More Catalyst Basics
- 安装 PostgreSQL 服务器,客户端,以及 DBD::Pg:
如果你是 Debian 5 平台, 可以使用一下命令快速安装:
- 安装 PostgreSQL 服务器,客户端,以及 DBD::Pg:
sudo aptitude install postgresql libdbd-pg-perl libdatetime-format-pg-perl |
配置权限,编辑 /etc/postgresql/8.3/main/pg_hba.conf 修改下面内容(文件底部):
# "local" is for Unix domain socket connections only |
变更为:
# "local" is for Unix domain socket connections only |
重启 PostgreSQL 服务:
sudo /etc/init.d/postgresql-8.3 restart |
- 创建数据库,添加用户,这里我们用"<catalyst>"表示你的密码:
$ sudo -u postgres createuser -P catappuser |
- 编写加载数据的 .sql 脚本:
- 编辑 myapp01_psql.sql :
-- |
- 加载数据:
$ psql -U catappuser -W catappdb -f myapp01_psql.sql |
- 查看一下,确保数据正确:
$ psql -U catappuser -W catappdb |
- 接下来几步:
edit lib/MyApp.pm |
- 生成 model(使用 Catalyst "_create.pl" 脚本):
$ rm lib/MyApp/Model/DB.pm # Delete just in case already there |
- 针对第四章: Basic CRUD
给 Books 表增加 Datetime 字段:
$ psql -U catappuser -W catappdb |
$ script/myapp_create.pl model DB DBIC::Schema MyApp::Schema \ |
- 针对第五章: Authentication
- Create the .sql file for the user/roles data:
创建脚本 myapp02_psql.sql :
-- |
- Load the data:
$ psql -U catappuser -W catappdb -f myapp02_psql.sql |
Confirm with:
$ psql -U catappuser -W catappdb -c "select * from users" |
- Modify set_hashed_passwords.pl to match the following (the only difference is the connect line):
#!/usr/bin/perl |
Run the set_hashed_passwords.pl as per the "normal" flow of the tutorial:
$ perl -Ilib set_hashed_passwords.pl |
You can verify that it worked with this command:
$ psql -U catappuser -W catappdb -c "select * from users" |
MySQL
略....