Thread: Re: GUI for Postgres Management? PostgreSQL vs MySQL.

Re: GUI for Postgres Management? PostgreSQL vs MySQL.

From
Matthew Nuzum
Date:
My 2 cents worth, since no one else has mentioned these on the list:

First of all, for a GUI admin tool, if you're running RedHat 7.3 (or 8.0
and you have a little patience) you can run the RedHat Database admin
tool.  You can download the ISO image from their website www.redhat.com
and install from there.  It's about 80 MB, so you'd need a fast
connection. I found it well worth the effort.

For MySQL vs. PostgreSQL; Like you, I questioned which was better for
me.  I started out using MySQL because of the great deal of initial
documentation in the PHP world.  Then I started using both Postgres and
MySQL depending on which one was available to me.  All of these jobs
were small sites that didn't need too much.  I could not see how either
database had an advantage in this realm, because they both performed
well.

The difference came when I started working on a slightly larger
projects.  I found that by using Postgres, I had to write less PHP code
to get my job done.  I used Views and User Defined Functions
(procedures) to make things easier.  I'll give you an example of what I
mean in just a moment.

To make an even stronger case for Postgres, just in the last two weeks,
I began using Triggers with my procedures.  Last night, I was able to
delete a couple hundred lines of PHP code from a single file because of
a 60 line procedure I was able to make.  It makes my PHP code much
simpler to read, manage and debug.

Here's a real simple example of a procedure that makes life easier.

Imagine a table that has this structure:
Table Name: stats
id (int)
account (int)
ip_address (varchar)
req_page (varchar)
req_time (timestamp)

It is a hit counter and stores a record for each page view that one of
your customer's websites gets.

You can then write two procedures that help you with the dates, they
would be:
this_month() - returns the first day of the current calendar month
next_month() - returns the first day of the next calendar month.

You can then simplify your code and your queries by doing something like
this:
      Select count(*) from stats where req_time
      BETWEEN this_month() and next_month();
This would show you the number of page views you've received the current
month.

You may be thinking, "Procedures?  You mean I have to learn another
language?"  Procedures are easy.  For many simple procedures, you simply
use SQL, which you probably already know.  Here's an example of how you
might write the "this_month()" function:

CREATE FUNCTION this_month() RETURNS timestamp AS '
SELECT date_trunc(''month'' FROM now());
' LANGUAGE 'sql';

Now that I know how to use these advanced features of Postgres, I find
that I use them all of the time in my functions.  I'd have a hard time
switching back to MySQL.

I suspect that you would have little problem using Postgres in place of
MySQL in your normal routine.

I hope this helps you choose the database tool that fits your needs,
Matthew Nuzum

> Hello,
>
> I am new to PostgreSQL.  I am wondering if there is currently a GUI
> management tool available to be used with PostgreSQL?  I am debating
> between MySQL and PostgreSQL.
>
> I like MySQL because of its GUI management tool and because (according
to
> soom books) its tight integration with PHP.
>
> On the other hand PostgreSQL has a PL/SQL "like" enhancement which I
really
> like too.
>
> I plan on installing on Linux for DB/Web application I am hoping to
build.
> Is there any performance advantages in using PostgreSQL over MYSQL?
>
> Any help would be appreciated in helping me make up my mind.
>
> Alex-
>
>
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now






Help with exporting data

From
Brent Wood
Date:

I have an application which is using Postgres to store/manage it's data.

I'd like to be able to export (to text files) the outputs from queries.

There are two ways I've found I can do this.

I can run a select from a shell & redirect the output to a file, then
reformat the file to plain whitespace delimited values.

I can create a new (possibly temp) table with select into & copy the
resulting table to a file. I can't see any other way in the docs, as copy
won't work with views.


Is there a simpler (& more efficient) way to get the result of a select
into a plain text file, without the Postgres header/trailer lines & the
"|" between attributes?


Thanks,

  Brent Wood


Re: Help with exporting data

From
Martijn van Oosterhout
Date:
Please don't hit reply to any email to start a new thread. This email was
attached to a thread from November 26.

On Fri, Feb 28, 2003 at 03:39:30PM +1300, Brent Wood wrote:

<snip>

> Is there a simpler (& more efficient) way to get the result of a select
> into a plain text file, without the Postgres header/trailer lines & the
> "|" between attributes?

Anyway, psql has a lot of options for controlling it's output. I usually
use:

psql '-F<tab>' -A -t -c "query"

-F    sets delimiter
-A    turns off alignment
-t    turns off header and footer

Hope this helps,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Support bacteria! They're the only culture some people have.

Attachment

Re: Help with exporting data

From
Jason Larke
Date:
>>>>> On Fri, 28 Feb 2003 15:39:30 +1300, Brent Wood
>>>>> <b.wood@niwa.co.nz> said:

BW> Is there a simpler (& more efficient) way to get the result
BW> of a select into a plain text file, without the Postgres
BW> header/trailer lines & the "|" between attributes?

There are psql options to turn off the headers and footers and to
select your own field seperator. You probably want some
combination of

\pset format unaligned
\pset tuples_only
\pset fieldsep 'field_seperator_character'

--
Jason Larke- jlarke@uu.net- http://www.nnaf.net/~jlarke Send mail for PGP key
I don't speak for UUNET or Worldcom. I speak for Odin. And he's *pissed*.
Any sufficiently advanced weapon is indistinguishable from a practical joke.
"People change, and smile: but the agony abides."-T.S. Eliot, The Dry Salvages