Re: Implementation Suggestions

Поиск
Список
Период
Сортировка
От Reid Thompson
Тема Re: Implementation Suggestions
Дата
Msg-id 442B31E8.10905@ateb.com
обсуждение исходный текст
Ответ на Re: Implementation Suggestions  ("Ian Harding" <iharding@destinydata.com>)
Список 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@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)








В списке pgsql-general по дате отправления:

Предыдущее
От: Chris
Дата:
Сообщение: Re: checking data type
Следующее
От: Tom Lane
Дата:
Сообщение: Re: EXPLAIN SELECT .. does not return