Re: Implementation Suggestions

From: Reid Thompson <Reid(dot)Thompson(at)ateb(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Implementation Suggestions
Date: 2006-03-30 01:18:32
Message-ID: 442B31E8.10905@ateb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ian Harding wrote:
>>>> I'm wondering if I could get some suggestions as to how implement
>>>> this quickly and simply? I was thinking a web interface using PHP
>>>> would be the fastest way of going about it.
>>>>
>
> If you used Ruby on Rails, you'd be finished by now. It slices, it
> dices, it makes julienne fries.
>
> Seriously, it's not too bad if you don't mind it's plentiful
> shortcomings. I was getting carpal tunnel syndrome from typing
> <scripting language> pages so I switched to RoR for a hobby app. It
> works fine, but you have to do it "The Rails Way" and expect no help
> from the "Community" because they are a fanboi cheerleader squad, not
> interested in silly stuff like referential integrity, functions,
> triggers, etc. All that nonsense belongs in the application!
>
> Check this out, there is no stale connection detection or handling in
> rails. I'm not kidding. If you connection drops out, restart your
> web server. Sorry. Blah.
>
> Anyway, besides its warts, it is dead easy to use, and does make
> putting together web applications in a "green field" scenario quite
> painless. Just don't try to do anything outside the box like trying
> to access an existing database that uses RDBMS features heavily and
> uses normal object naming.
>
> - Ian
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>
re: ruby && postgres -- i'll throw nitro and og into the hat.
http://nitrohq.com
nitro is the web presentation framework, Og is the ORM...
----------------------------------------------
require 'og'

class Comment
property :title, String, :sql => 'VARCHAR(60) NOT NULL'
property :body, String
property :author, String
property :create_time, Time
def initialize( title = '', body = '', author = '', time = Time.now )
@title = title
@body = body
@author = author
@create_time = time
end
end

og_psql = {
:destroy_tables => true, # don't use this on a DB with tables that
you DO NOT want to lose -- or set to false
:store => :psql,
:user => 'rthompso',
:password => 'rthompso',
:name => 'test'
}

#Og.table_prefix = '' # remove og generated table prefix
db = Og.setup(og_psql)
c = Comment.new('Title', 'Body', 'Author')
# or
# c = Comment.new
# c.title = 'Hello'
# c.body = 'World'
# c.create_time = Time.now
# c.author = 'tml'
c.save

------------------------------
$ ruby -rubygems pgtest.rb
I, [2006-03-29T20:16:50.278205 #16029] INFO -- : Og uses the Psql store.
D, [2006-03-29T20:16:50.637238 #16029] DEBUG -- : Dropped database table
ogcomment
I, [2006-03-29T20:16:50.943499 #16029] INFO -- : Created table 'ogcomment'.
D, [2006-03-29T20:16:50.963087 #16029] DEBUG -- : PostgreSQL processing
foreign key constraints
D, [2006-03-29T20:16:50.963532 #16029] DEBUG -- : PostgreSQL finished
setting constraints. No action was taken in 0.00 seconds.
rthompso(at)yos:/home/rthompso>
$ psql test -c "select * from ogcomment;"
title | body | author | create_time | oid
-------+------+--------+---------------------+-----
Title | Body | Author | 2006-03-29 20:16:50 | 1
(1 row)

$ psql test -c "\d ogcomment;"
Table "public.ogcomment"
Column | Type |
Modifiers
-------------+-----------------------------+---------------------------------------------------------
title | character varying(60) | not null
body | text |
author | text |
create_time | timestamp without time zone |
oid | integer | not null default
nextval('ogcomment_oid_seq'::regclass)
Indexes:
"ogcomment_pkey" PRIMARY KEY, btree (oid)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Klint Gore 2006-03-30 01:41:50 Re: Is this possible.
Previous Message sylsau 2006-03-30 01:17:48 Use functions in Pl/Perl language