Unix Technical Forum

Re: Change the Default Database

This is a discussion on Re: Change the Default Database within the pgsql Sql forums, part of the PostgreSQL category; --> Hi Rommel, I thought I'd throw a little more input in, as an alternative to psql. I use Ruby ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Sql

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 03:09 PM
Steve Midgley
 
Posts: n/a
Default Re: Change the Default Database

Hi Rommel,

I thought I'd throw a little more input in, as an alternative to psql.
I use Ruby on Rails with Postgres, and for testing, it drops the
testing database, recreates it and loads the structures dumped from the
development database, before running tests - to ensure a clean test
every time (it also has a tool for re-building the development database
programatically, which one can run before all this).

So, Rails has to solve the same problem you have, and it doesn't use
psql to do it. My investigation into it's method is as so:

1) Initiate a connection to Pg server via Pg network port.
1.a) Dump dev database structures to file
2) Drop database 'test'
3) Create database 'test' (with correct parameters)
4) Initiate a new connection to Pg server via port, request connection
to newly created 'test' database
5) Load dev database structures from file to 'test' database.

The key obviously is reconnecting over the port connection and
specifying the database you wish to connect to - I think this is how
PGAdmin does the job too (when you click on "SQL" you're making a port
level connection to the server, specifying which database you want to
talk with - from what I can tell, Pg doesn't let you operate across
databases, as MS SQL does - one connection = one database).

I'm not nearly as expert as others on the list, so any corrections to
the above analysis would be welcome.

Sincerely,

Steve


At 04:49 AM 2/27/2007, pgsql-sql-owner@postgresql.org wrote:
>Date: Mon, 26 Feb 2007 18:02:38 -0400
>From: "Rommel the iCeMAn" <icecrew@gmail.com>
>To: <pgsql-sql@postgresql.org>
>Subject: Re: Change Default Database
>Message-ID: <00d301c759f1$d61c2e70$b364a8c0@theport.com>
>
>I seem to be blundering a lot today! I thought I was replying to the
>entire
>list, didn't realize I replied to one person :-)
>
>Nothing was wrong with my script, I assumed that since it was
>generated by
>pgAdmin that I could run it inside pgAdmin. It works perfectly when I
>run it
>using psql. It is very much like SQL Server's osql command line tool.
>Thanks
>to everyone that helped ...
>
>So I've learnt three valuable lessons:
>
>1. It's better to execute scripts using the command line tool 'psql'.
>
>2. Make sure I'm replying to the list and not to an individual.
>
>3. Do not post HTML messages!!! :-))
>
>
>Thanks again everyone.
>
>Rommel Edwards
>Software Developer,
>Barbados, Caribbean.



---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 03:09 PM
Rommel the iCeMAn
 
Posts: n/a
Default Re: Change the Default Database

Hi Steve,

Thanks for the alternative method, I will give that a try as well. It's nice
to know there is more than one road to reach a destination.

Thanks again,
Rommel Edwards
Software Developer,
Barbados, Caribbean.


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:44 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com