[GENERAL] time without time zone

2007-06-18 Thread Garry Saddington
This is a select on table periods defined as such:
CREATE TABLE periods
(
  periodid serial NOT NULL,
  periodnumber integer NOT NULL,
  periodstart time without time zone,
  periodend time without time zone,
  PRIMARY KEY (periodid)
)

PeriodidPeriodnumberPeriodstart Periodend
6   1   2007/06/18 09:00:00 GMT+0   2007/06/18 09:30:00 GMT+0
7   2   2007/06/18 09:30:00 GMT+0   2007/06/18 10:00:00 GMT+0
8   3   2007/06/18 10:00:00 GMT+0   2007/06/18 10:30:00 GMT+0
9   4   2007/06/18 10:30:00 GMT+0   2007/06/18 11:00:00 GMT+0
10  5   2007/06/18 11:30:00 GMT+0   2007/06/18 12:00:00 GMT+0
11  6   2007/06/18 13:00:00 GMT+0   2007/06/18 13:30:00 GMT+0
12  7   2007/06/18 13:30:00 GMT+0   2007/06/18 14:00:00 GMT+0
13  8   2007/06/18 14:00:00 GMT+0   2007/06/18 14:30:00 GMT+0

Can anyone explain why time has todays date and time zone? I am confused, I 
only want time, such as:
13:00:00
regards
garry

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


Re: [GENERAL] time without time zone

2007-06-18 Thread Garry Saddington
On Monday 18 June 2007 21:15, Tom Lane wrote:
> Garry Saddington <[EMAIL PROTECTED]> writes:
> > Can anyone explain why time has todays date and time zone?
>
> Works for me:
>
> regression=# insert into periods values(1,1,'now','now');
> INSERT 0 1
> regression=# select * from periods;
>  periodid | periodnumber |  periodstart   |   periodend
> --+--++
> 1 |1 | 16:13:14.35962 | 16:13:14.35962
> (1 row)
>
> I speculate that you are trying to display the table in some client
> software that doesn't know the time datatype and is forcibly converting
> it to something it does know.
>
>   regards, tom lane
Yes, you are correct I am in Zope using ZpsycopgDA. Just tried on the command 
line and the behaviour is correct. Time to ask elsewhere, thanks.
regards
garry

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


Re: [GENERAL] Excell

2007-06-20 Thread Garry Saddington
On Wednesday 20 June 2007 03:09, Bob Pawley wrote:
> Thanks
>
> Does one version of ODBC work for all versions of Excel and Postgresql.
>
> I am wanting to transfer one or two tables from Excel and manipulate the
> information in Postgresql then transfer the results back to Excel as a
> single table.
>
> I am using Excel 2000 and PostgreSql 8.1.
>
Save as CSV from Excel and use Posrgres 'copy' command to import the data, 
would be a straightforward solution, works both ways -copy to, copy from.
http://www.postgresql.org/docs/8.2/static/sql-copy.html

Regards
Garry

---(end of broadcast)---
TIP 6: explain analyze is your friend


[GENERAL] execute pg_dump via python

2007-10-25 Thread Garry Saddington
I am using zope on windows with an external python method to backup my 
database. I am struggling to run the following command:

pg_dump.exe database > file

I have tried using os.popen - no luck
and also subprocess.Popen.

eg:
import subprocess

subprocess.Popen(['c:/dir/dir/pg_dump.exe','database','>','c:/dir/dir/output 
file'])

The command string works perfectly in a terminal. Does anyone know how I 
should be doing this? I get no errors or traceback when I try the method 
through Zope.

regards
garry

---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster


Re: [GENERAL] first message: SELECT FROM

2008-02-02 Thread Garry Saddington
On Saturday 02 February 2008 17:43, Aílsom F. Heringer wrote:
> Hi,
> This is my first message, and I need some help. I have just installed
> Postgresql 8.2. (Windows).
>
> At pgAdmin III Query, when I send SELECT * FROM USUARIOS, I get all
> columns correctly. But when I try to get only one column, SELECT senha
> FROM USUARIOS, I get the error message:
>
> ERROR: column "senha" does not exist
> SQL state: 42703
> Character: 8
>
> What is the problem ?
Please post your table definition so that we can see what you are selecting 
from. If you were one of my students I would say "check your table definition 
or your spelling".
Regards
Garry

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

   http://archives.postgresql.org/


Re: [GENERAL] Find Number Of Sundays Between Two Dates

2008-03-05 Thread Garry Saddington
On Wednesday 05 March 2008 06:16, raghukumar wrote:
> Hai EverBody,
>
> Can I know what is the query by which we can find the number of
> sundays between two given dates in postgres
>
> Thanks In Advance,
> Raghu...
I think the easiest way is to set up a table populated with all dates and days 
between two years that are important to your application and then just do 
simple selects on that table.
Regards
Garry

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


[GENERAL] two not null columns

2008-04-14 Thread Garry Saddington
How would I write a table check constraint to make sure that two columns don't 
both have nulls at the same time.
The following doesn't do it because it because it does not allow one column to 
be null while the other holds data?

check(teachgroup is not null AND set is not null)

regards
garry

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] two not null columns

2008-04-14 Thread Garry Saddington
On Monday 14 April 2008 17:44, Andreas Kretschmer wrote:
> Garry Saddington <[EMAIL PROTECTED]> schrieb:
> > How would I write a table check constraint to make sure that two columns
> > don't both have nulls at the same time.
> > The following doesn't do it because it because it does not allow one
> > column to be null while the other holds data?
> >
> > check(teachgroup is not null AND set is not null)
>
> test=# create table not_null (a int, b int, check((a is not null) or (b is
> not null))); CREATE TABLE
> test=*# insert into not_null values (1,1);
> INSERT 0 1
> test=*# insert into not_null values (1,NULL);
> INSERT 0 1
> test=*# insert into not_null values (null,2);
> INSERT 0 1
> test=*# insert into not_null values (null,null);
> ERROR:  new row for relation "not_null" violates check constraint
> "not_null_check"
Works great, thanks
regards
garry

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] UTF8 encoding problem

2008-06-17 Thread Garry Saddington
I am getting illegal UTF8 encoding errors and I have traced it to the £ sign.
I have set lc_monetary to "lc_monetary = 'en_GB.UTF-8'" in postgresql.conf but 
this has no effect. How can I sort this problem? Client_encoding =UTF8.
Regards
Garry

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] UTF8 encoding problem

2008-06-17 Thread Garry Saddington
On Wednesday 18 June 2008 02:04, Michael Fuhr wrote:
> On Tue, Jun 17, 2008 at 10:48:34PM +0100, Garry Saddington wrote:
> > I am getting illegal UTF8 encoding errors and I have traced it to the £
> > sign.
>
> What's the exact error message?
>
> > I have set lc_monetary to "lc_monetary = 'en_GB.UTF-8'" in
> > postgresql.conf but this has no effect. How can I sort this problem?
> > Client_encoding =UTF8.
>
> Is the data UTF-8?  If the error is 'invalid byte sequence for encoding
> "UTF8": 0xa3' then you probably need to set client_encoding to latin1,
> latin9, or win1252.
>
Thanks, that's fixed it.
Garry

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] UTF8 encoding problem

2008-06-18 Thread Garry Saddington
On Wednesday 18 June 2008 14:00, Michael Fuhr wrote:
> On Wed, Jun 18, 2008 at 08:25:07AM +0200, Giorgio Valoti wrote:
> > On 18/giu/08, at 03:04, Michael Fuhr wrote:
> > > Is the data UTF-8?  If the error is 'invalid byte sequence for
> > > encoding "UTF8": 0xa3' then you probably need to set client_encoding
> > > to latin1, latin9, or win1252.
> >
> > Why?
>
> UTF-8 has rules about what byte values can occur in sequence;
> violations of those rules mean that the data isn't valid UTF-8.
> This particular error says that the database received a byte with
> the value 0xa3 (163) in a sequence of bytes that wasn't valid UTF-8.
>
> The UTF-8 byte sequence for the pound sign (£) is 0xc2 0xa3.  If
> Garry got this error (I don't know if he did; I was asking) then
> the byte 0xa3 must have appeared in some other sequence that wasn't
> valid UTF-8.  The usual reason for that is that the data is in some
> encoding other than UTF-8.
>
> Common encodings for Western European languages are Latin-1
> (ISO-8859-1), Latin-9 (ISO-8859-15), and Windows-1252.  All three
> of these encodings use a lone 0xa3 to represent the pound sign.  If
> the data has a pound sign as 0xa3 and the database complains that
> it isn't part of a valid UTF-8 sequence then the data is likely to
> be in one of these other encodings.
>
Thanks, I have traced it to a client_encoding problem and set it to latin1 
which has cured the problem.
regards
garry

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] Losing data

2008-06-19 Thread Garry Saddington
I have had a serious loss of data and wondered if anyone could shed any light 
on what may have happened.
My users have been writing reports on students. No error messages have been 
produced and when called back up the reports seem to be present at the time 
of writing. However, next day they have disappeared, and they do not appear 
in a pg_dump. They seem to have been kept in memory and never written to 
disk.
We are using Zope and connecting to Postgres through psycopg on Centos 5.
I suspect a hard disk failure but any other ideas would be welcome.
Would these reports be in the WAL?
regards
garry

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Losing data

2008-06-19 Thread Garry Saddington
On Thursday 19 June 2008 16:55, Joshua D. Drake wrote:
> On Thu, 2008-06-19 at 16:55 +0100, Garry Saddington wrote:
> > I have had a serious loss of data and wondered if anyone could shed any
> > light on what may have happened.
> > My users have been writing reports on students. No error messages have
> > been produced and when called back up the reports seem to be present at
> > the time of writing. However, next day they have disappeared, and they do
> > not appear in a pg_dump. They seem to have been kept in memory and never
> > written to disk.
> > We are using Zope and connecting to Postgres through psycopg on Centos 5.
> > I suspect a hard disk failure but any other ideas would be welcome.
> > Would these reports be in the WAL?
>
> If it was hardware related you would know, quickly. This sounds a great
> deal more like an application level interaction. Perhaps your zope
> application caches things for a while before committing to disk?
Yes I thought of this but once the report is sent to the DB a separate query 
is run to get all of that teacher's reports and these are then displayed on a 
new page. They all appear here but then disappear later. Zope has transaction 
machinery that rolls everything back on an error, so Postgres must have 
indicated a successful write somehow.  I read in a Postgres manual that the 
hard disk may report to the OS that a write has occured when it actually has 
not, is this possible? Oh, and the problem has been intermittant. Another 
thing that happened this morning is that Postgres had today as 18/06/2008 
when in fact it was 19/06/2008 and the OS reported this correctly. Restarting 
postgres sorted it, could this be the problem?
Regards
Garry

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Losing data

2008-06-19 Thread Garry Saddington
On Thursday 19 June 2008 18:10, Bill Moran wrote:
> In response to Garry Saddington <[EMAIL PROTECTED]>:
> > On Thursday 19 June 2008 16:55, Joshua D. Drake wrote:
> > > On Thu, 2008-06-19 at 16:55 +0100, Garry Saddington wrote:
> > > > I have had a serious loss of data and wondered if anyone could shed
> > > > any light on what may have happened.
> > > > My users have been writing reports on students. No error messages
> > > > have been produced and when called back up the reports seem to be
> > > > present at the time of writing. However, next day they have
> > > > disappeared, and they do not appear in a pg_dump. They seem to have
> > > > been kept in memory and never written to disk.
> > > > We are using Zope and connecting to Postgres through psycopg on
> > > > Centos 5. I suspect a hard disk failure but any other ideas would be
> > > > welcome. Would these reports be in the WAL?
> > >
> > > If it was hardware related you would know, quickly. This sounds a great
> > > deal more like an application level interaction. Perhaps your zope
> > > application caches things for a while before committing to disk?
> >
> > Yes I thought of this but once the report is sent to the DB a separate
> > query is run to get all of that teacher's reports and these are then
> > displayed on a new page. They all appear here but then disappear later.
> > Zope has transaction machinery that rolls everything back on an error, so
> > Postgres must have indicated a successful write somehow.  I read in a
> > Postgres manual that the hard disk may report to the OS that a write has
> > occured when it actually has not, is this possible?
>
> No.  If that happens you end up with corrupt disks.  The chance of that
> going unnoticed by the OS is pretty slim.
>
> > Oh, and the problem has been intermittant. Another
> > thing that happened this morning is that Postgres had today as 18/06/2008
> > when in fact it was 19/06/2008 and the OS reported this correctly.
> > Restarting postgres sorted it, could this be the problem?
>
> Sounds to me like there's something seriously wrong with you OS or your
> PostgreSQL install.  What version of PostgreSQL is this?  What OS?
>
> --
Centos 5 with the Posgres that comes with it - 8.1
regards
garry

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Losing data

2008-06-19 Thread Garry Saddington
On Thursday 19 June 2008 18:15, Alan Hodgson wrote:
> On Thursday 19 June 2008, Garry Saddington <[EMAIL PROTECTED]>
>
> wrote:
> > I read in a
> > Postgres manual that the hard disk may report to the OS that a write has
> > occured when it actually has not, is this possible?
>
> Yeah. But unless the power suddenly turned off that wouldn't cause data
> loss.
>
> > Oh, and the problem
> > has been intermittant. Another thing that happened this morning is that
> > Postgres had today as 18/06/2008 when in fact it was 19/06/2008 and the
> > OS reported this correctly. Restarting postgres sorted it, could this be
> > the problem?
>
> I strongly suspect the problem is between the keyboard and the chair.
I'd love to agree, but I have seen this first hand as a user!
>
> In any case, however, if PostgreSQL reported the transaction complete and
> the machine didn't experience any hardware problems (like sudden power or
> disk failure), I would certainly not suspect PostgreSQL as the source of
> the problem.
What has happened to the reports then? I have used this combination of Zope 
and Postgres for 5 years with no problems like this before and we have 
written one complete set of reports on this server in the past 6 weeks. The 
problem seems to have started last friday, when reports started to go 
missing.
regards
Garry

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Losing data

2008-06-19 Thread Garry Saddington
On Thursday 19 June 2008 18:09, Scott Marlowe wrote:
> On Thu, Jun 19, 2008 at 9:55 AM, Garry Saddington
>
> <[EMAIL PROTECTED]> wrote:
> > I have had a serious loss of data and wondered if anyone could shed any
> > light on what may have happened.
> > My users have been writing reports on students. No error messages have
> > been produced and when called back up the reports seem to be present at
> > the time of writing. However, next day they have disappeared, and they do
> > not appear in a pg_dump. They seem to have been kept in memory and never
> > written to disk.
> > We are using Zope and connecting to Postgres through psycopg on Centos 5.
> > I suspect a hard disk failure but any other ideas would be welcome.
> > Would these reports be in the WAL?
> > regards
>
> Just a guess, but do you have some kind of search engine pointing at
> the application?  Could it be hitting a "delete" link maybe?
Don't think so, once a teacher has entered a report there is no way that they 
can delete it.
Regards
Garry

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Losing data

2008-06-19 Thread Garry Saddington
On Thursday 19 June 2008 18:52, Adrian Klaver wrote:
> -- Original message --
> From: Garry Saddington <[EMAIL PROTECTED]>
>
> > On Thursday 19 June 2008 16:55, Joshua D. Drake wrote:
> > > On Thu, 2008-06-19 at 16:55 +0100, Garry Saddington wrote:
> > > > I have had a serious loss of data and wondered if anyone could shed
> > > > any light on what may have happened.
> > > > My users have been writing reports on students. No error messages
> > > > have been produced and when called back up the reports seem to be
> > > > present at the time of writing. However, next day they have
> > > > disappeared, and they do not appear in a pg_dump. They seem to have
> > > > been kept in memory and never written to disk.
> > > > We are using Zope and connecting to Postgres through psycopg on
> > > > Centos 5. I suspect a hard disk failure but any other ideas would be
> > > > welcome. Would these reports be in the WAL?
> > >
> > > If it was hardware related you would know, quickly. This sounds a great
> > > deal more like an application level interaction. Perhaps your zope
> > > application caches things for a while before committing to disk?
> >
> > Yes I thought of this but once the report is sent to the DB a separate
> > query is run to get all of that teacher's reports and these are then
> > displayed on a new page. They all appear here but then disappear later.
> > Zope has transaction machinery that rolls everything back on an error, so
> > Postgres must have indicated a successful write somehow.  I read in a
> > Postgres manual that the hard disk may report to the OS that a write has
> > occured when it actually has not, is this possible? Oh, and the problem
> > has been intermittant. Another thing that happened this morning is that
> > Postgres had today as 18/06/2008 when in fact it was 19/06/2008 and the
> > OS reported this correctly. Restarting postgres sorted it, could this be
> > the problem?
> > Regards
> > Garry
>
> Seems like a transaction with no commit. Basically along as the session is
> active the data is there but once the session is closed the data does not
> persist.
>
Makes sense but what is to blame?
Regards
Garry

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Losing data

2008-06-19 Thread Garry Saddington
On Thursday 19 June 2008 19:03, Joshua D. Drake wrote:
> On Thu, 2008-06-19 at 19:06 +0100, Garry Saddington wrote:
> > On Thursday 19 June 2008 18:15, Alan Hodgson wrote:
> > > On Thursday 19 June 2008, Garry Saddington <[EMAIL PROTECTED]>
>
> Although I appreciate that this is a funky problem, the problem doesn't
> yet exist and we are operating in a diagnostic vacuum.
>
> Can you duplicate the problem now?
The problem is not consistent, some reports are lsot others not.
>
> Do you have any logs from PostgreSQL that describe the session that
> either previously or currently (based on your tests) the problem?
These are at school so I will look tomorrow

>
> Do those logs actually show ERROR?
There are no errors relating to reports
>
> What about your apachelog or zope logs?
Again tomorrow
>
> Have you turned up the logging in all three components to ensure that
> the problem actually does exist?
Will do this tomorrow
regards and thanks for your efforts.

PS
Could it be somethiing to do with libpq.so.4/5 required by psycopg and will 
the WAL hold data to be replayed?

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Losing data

2008-06-19 Thread Garry Saddington
On Friday 20 June 2008 05:26, Robert Treat wrote:
> On Thursday 19 June 2008 14:06:38 Garry Saddington wrote:
> > > In any case, however, if PostgreSQL reported the transaction complete
> > > and the machine didn't experience any hardware problems (like sudden
> > > power or disk failure), I would certainly not suspect PostgreSQL as the
> > > source of the problem.
> >
> > What has happened to the reports then? I have used this combination of
> > Zope and Postgres for 5 years with no problems like this before and we
> > have written one complete set of reports on this server in the past 6
> > weeks. The problem seems to have started last friday, when reports
> > started to go missing.
>
> Out of curiosity, what is your vacuum strategy?
We back up and vacuum at the same time each day.
garry

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] Unicode problem again

2008-06-23 Thread Garry Saddington
I have the following error:
Postgres 8.3 via psycopg 1.1.21 and zope 2.10.

ProgrammingError Error Value: ERROR: character 0xe28099 of encoding "UTF8" has 
no equivalent in "LATIN1" select distinct teachers.teacherid,teachers.teacherid 
as thisteacherid,teachers.initials, 
reports.reporttext,reports.reportid,subjects.subjectid ,subjects.name, 
subjects.abbreviation,reports.academicyear,teachers.firstname as 
first,teachers.surname as second,classes.classid from classes, 
reports,teachers,subjects where reports.classid=classes.classid and 
reports.teacherid=teachers.teacherid and reports.studentid=4247 and 
classes.subjectid=subjects.subjectid and reports.classid=5626 and 
reports.teacherid=30

I have changed client_encoding to Latin1 to get over errors caused by having 
the database in UTF8 and users trying to enter special characters like £ signs.
Unfortunately, it seems there are already UTF8 encodings in the DB that have no 
equivalent in Latin1 from before the change.
How can I get over this problem, and still allow special characters, ie have no 
error reports.
Regards
Garry

Re: [GENERAL] Unicode problem again

2008-06-26 Thread Garry Saddington
On Thursday 26 June 2008 15:41, Michael Fuhr wrote:
> On Thu, Jun 26, 2008 at 03:31:01PM +0200, Albe Laurenz wrote:
> > Michael Fuhr wrote:
> > > Your input data seems to have a mix of encodings: sometimes you're
> > > getting pound signs in a non-UTF-8 encoding, but if characters like
> > >  got into the database when
> > > client_encoding was set to UTF8 then at least some data must have
> > > been in UTF-8.
> >
> > Sorry, but that's not true.
> > That character is 0x9s in WINDOWS-1252.
>
> I think you mean 0x92.
>
> > So it could have been that client_encoding was (correctly) set to WIN1252
> > and the quotation mark was entered as a single byte character.
>
> Yes, *if* client_encoding was set to win1252.  However, in the
> following thread Garry said that he was getting encoding errors
> when entering the pound sign that were resolved by changing
> client_encoding (I suggested latin1, latin9, or win1252; he doesn't
> say which he used):
>
> http://archives.postgresql.org/pgsql-general/2008-06/msg00526.php
>
> If client_encoding had been set to win1252 then Garry wouldn't have
> gotten encoding errors when entering the pound sign because that
> character is 0xa3 in win1252 (also in latin1 and latin9). So either
> applications are setting client_encoding to different values,
> sometimes correctly and sometimes incorrectly (Garry, do you know
> if that could be happening?), or the data is sometimes in different
> encodings.  If the data is being entered via a web application 
This is the case and so I need some way to tell the browser to send the 
correct encoding - still researching.
regards
Garry


> then 
> the latter seems more likely, at least in my experience (I've had
> to deal with exactly this problem recently).
>
> --
> Michael Fuhr

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] running pg_dump from python

2009-06-14 Thread Garry Saddington
I ahve the following python file that I am running as an external method 
in Zope.


def backup():
   import  os
   os.popen("c:/scholarpack/postgres/bin/pg_dump scholarpack  > 
c:/scholarpack/ancillary/scholarpack.sql")

   data=open('c:/scholarpack/ancillary/scholarpack.sql','r')
   r=data.read()
   data.close
   return r

However, when I run this script it creates the file scholarpack.sql but 
the file is empty.

Any help much appreciated.
Regards
Garry

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] running pg_dump from python

2009-06-14 Thread Garry Saddington

Scott Mead wrote:
On Sun, Jun 14, 2009 at 4:06 PM, Garry Saddington 
mailto:ga...@schoolteachers.co.uk>> wrote:


I ahve the following python file that I am running as an external
method in Zope.

def backup():
  import  os
  os.popen("c:/scholarpack/postgres/bin/pg_dump scholarpack  >
c:/scholarpack/ancillary/scholarpack.sql")


Have you tried running that command on the command line by itself 
(as the same user that runs the phython)?  If that gives you the same 
result, then you know for sure that it's a function of the pg_dump 
options and not the python script.


Are you looking for the full SQL of the scholarpack database?


Yes
What user is this running as? 
scholarpack but no OS user scholarpack, but why should it create a file 
then not fill the contents?
Remember, in your case, pg_dump is going to try to connect as the OS 
username running your script.  you may want to include the username 
option to pg_dump:


 pg_dump -U  scholarpack
Zope is running as user scholarpack and I have tried the above as -U 
scholarpack and it works




 Try running that on the commandline first, by itself, as the same 
user that runs the python script. 


Looks like the script is at fault
regards
Garry


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] distributing postgresql binaries

2009-08-01 Thread Garry Saddington
I have developed an application using Zope and Postgresql and I want to 
be able to distribute the application with a full database of data so 
that there are no setup worries for users. The platform is Windows. When 
I copy the app over to windows XP home, Postgres refuses to start and I 
get a cryptic 'Application is configured wrongly' message from windows. 
It seems that the absence of registry entries (done some testing) is the 
problem. Is there a distribution that will run when copied from one 
machine to another without writing anything in the registry? By the way, 
I tried the binaries only install from the download area for 8.3.7 and 
it won't start either with the same error message. Any help would be 
much appreciated.

Regards
Garry

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] distributing postgresql binaries

2009-08-01 Thread Garry Saddington

Alan McKay wrote:

Why not populate the registry properly?

It is not that difficult to do.


  

Good idea, but where do I find the correct entries?
Regards
Garry

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] distributing postgresql binaries

2009-08-01 Thread Garry Saddington

Garry Saddington wrote:
I have developed an application using Zope and Postgresql and I want 
to be able to distribute the application with a full database of data 
so that there are no setup worries for users. The platform is Windows. 
When I copy the app over to windows XP home, Postgres refuses to start 
and I get a cryptic 'Application is configured wrongly' message from 
windows. It seems that the absence of registry entries (done some 
testing) is the problem. Is there a distribution that will run when 
copied from one machine to another without writing anything in the 
registry? By the way, I tried the binaries only install from the 
download area for 8.3.7 and it won't start either with the same error 
message. Any help would be much appreciated.

Regards
Garry

I have solved this problem. It's not the registry that is the problem it 
is the visual c++ runtime that is missing on Windows xp home. Installing 
vcredist_x86.exe as supplied with the msi installer corrects the problem.

Regards
Garry

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] difficulty running pg on XP as appl.

2009-08-13 Thread Garry Saddington

PG Subscriber wrote:

I'm on Windows XP SP 2, trying to run PostgreSQL 8.3.4.

Running postgres.exe gives the error:

"Execution of PostgreSQL by a user with administrative permissions is
not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromises. See the documentation for more
information on how to properly start the server.
"


Now, at the postgres wiki it says:
http://wiki.postgresql.org/wiki/Running_%26_Installing_PostgreSQL_On_Native_Windows#Why_do_I_need_a_non-administrator_account_to_run_PostgreSQL_under.3F
" Why do I need a non-administrator account to run PostgreSQL under?

When a hacker gains entry to a computer using a software bug in a
package, she gains the permissions of the user account under which the
service is run. Whilst we do not know of any such bugs in PostgreSQL, we
enforce the use of a non-administrative service account to minimise the
possible damage that a hacker could do should they find and utilise a
bug in PostgreSQL to hack the system.

This has long been common practice in the Unix world, and is starting to
become standard practice in the Windows world as well as Microsoft and
other vendors work to improve the security of their systems.

Note, that with the release of PostgreSQL 8.2, it is possible to run
under a administrative account. PostgreSQL 8.2 and above are able to
irrevocably give up administrative rights at startup thus ensuring the
rest of the system remains secure in the extremely unlikely event that
PostgreSQL becomes compromised.
"


So, I'm running a recent enough version of pg, now how do I get it to
drop Administrator privs so it will run, rather than give me an error?
Is there some special command line -c option or something (I would have
thought this would be outomatic, but evidently not)?


TIA


Try using pg_ctl to start the server.
Regards
Garry
begin:vcard
fn:Garry Saddington
n:Saddington;Garry
org:ScholarPack Ltd.
adr:;;Histon House;Hogsthorpe;Lincolnshire;PE24 5QA;England
email;internet:ga...@scholarpack.com
title:Lead Developer/C.E.O
tel;work:01754 871243
tel;cell:07817730615
x-mozilla-html:FALSE
url:www.scholarpack.com
version:2.1
end:vcard


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Trying to install ODBC driver on Windows XP notebook

2010-06-22 Thread Garry Saddington

Phil Jackson wrote:
I have latest Postgresql installed on a notebook and now trying to 
install the driver which I have downloaded and run so that it is now 
available in the ODBC Data Source Administrator


This machine has CA security suite, latest version installed and I have 
added a network rule that allows all applications using TCP and UDP on 
Port 4532 to gain access In and Out


Is port *4532* above a typo?


No Connection could be made because the target machine actively refused it.
(192.168.1.7:5432)


Regards
Garry


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Open Source Forum Software using PostgreSQL?

2010-07-04 Thread Garry Saddington

Andre Lopes wrote:

Hi,

I need to use an Forum Software. There is any Open Souce Forum Script 
using PostgreSQL?


Best Regards,
André.

Zforum does, but you will need to install Zope to run it.
Garry

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] filter tables from database

2010-08-11 Thread Garry Saddington
I can retrieve the table names in my database, but I would like to 
filter them based on the name of a field. Is this possible?

Thanks
Garry

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] disappearing data

2010-08-23 Thread Garry Saddington
We have had a problem with postgresql 8.3 on a Windows server 2008. I 
wonder whether there has been any other experiences like this. We have 
connected to Potsgres from Zope via a Psycopg adapter and noticed that 
sometimes when data is inserted via a form in Zope, the data is 
available in Zope but doesn't get committed to the database. This has 
come to a head over the weekend where at least one month's worth of data 
has disappeared and this includes changes to the actual database 
structure - luckily only on a testing machine, but concerning nevertheless.
The data seemed to disappear after we upgraded to the most recent 
version of Zpsycopg2 database adapter, previously we were using version 
1 (I know it's old, we are only testing after all) and have never had 
these sorts of problem before. It's almost as if all the data and 
changes to the db were held in memory, and Postgres continued to work 
fine from there, but when the db adapter was changed and Zope restarted 
everything was cleared from memory.
Has anyone had similar experinces or can anyone cast any light on where 
the problem may lie. To us it seems the db adapter is the most likely 
candidate but we can't understand how this could happen, explanations 
also welcome.

Regards
Garry

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] regexp help

2008-07-09 Thread Garry Saddington
I have the following simple regular expression:

"SELECT substring(addressline1 from '(^[0-9]+)') from addresses"

How could I find non-matches of this same pattern?
regards
Garry

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] query takes a long time

2008-08-23 Thread Garry Saddington
Can someone suggest how I could speed up the execution of this query?


select count(distinct attendance.studentid)
from attendance
where attendance.studentid not in (select studentid from attendance where auth 
not in('C','E','F','G','H','I','M','N','O','R','S','T','U'))

It returns the correct results but very slowly.
regards
garry

[GENERAL] case expression

2008-09-24 Thread Garry Saddington
Can anyone tell me why this will not work?

select *,
CASE WHEN postcode ilike '%OO%' THEN ''
  
END
from addresses
where studentid=1234
and addresstype='C'

There are postcodes like this: OO00 0OO

Regards
Garry

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] case expression

2008-09-24 Thread Garry Saddington
On Wednesday 24 September 2008 21:03, Tom Lane wrote:
> Garry Saddington <[EMAIL PROTECTED]> writes:
> > Can anyone tell me why this will not work?
> >
> > select *,
> > CASE WHEN postcode ilike '%OO%' THEN ''
> > END
> > from addresses
> > ...
>
> Define "not work".  What are you expecting it to do versus what
> really happens?
>
> Right offhand it looks like the CASE will return either an empty
> string or a NULL, which doesn't seem particularly useful ...
>
>   regards, tom lane
It does work but returns a column called case. How can I return the case 
column as 'postcode'?

Regards
garry

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] grant privileges

2008-11-08 Thread Garry Saddington
Is there a way to grant all priveleges on all tables and sequences in a 
database at the same time?
regards
Garry

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] grant privileges

2008-11-08 Thread Garry Saddington
On Saturday 08 November 2008 13:01, Andreas Kretschmer wrote:
> Garry Saddington <[EMAIL PROTECTED]> schrieb:
> > Is there a way to grant all priveleges on all tables and sequences in a
> > database at the same time?
>
Thanks I've just installed pgAdmin and that has done the trick.
Regards
Garry

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] aggregates and case statements

2008-11-16 Thread Garry Saddington
Is there a way to make the following statement return the total of all effort. 
At the moment it gives a list of sum vs case.


select sum(effort), 
CASE WHEN effortandattainment.effort=5 THEN -3
WHEN effortandattainment.effort=4 THEN -2
WHEN effortandattainment.effort=3 THEN 1
WHEN effortandattainment.effort=2 THEN 2
WHEN effortandattainment.effort=1 THEN 3

   END
from effortandattainment
group by case


Regards
Garry

[GENERAL] all empty tables

2009-11-14 Thread Garry Saddington

How could I list all the tables in a database that do not contain any data?
I have looked at reltuples but can't quite work out how to use it, any 
pointers would be much apreciated.

Regards
Garry

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] modelling question

2009-12-19 Thread Garry Saddington
Anyone have any ideas/suggestions on how to model siblings in a database 
so that it is possible to eg. only send letters to the parents once. In 
this scenario each sibling has the contact parents input separately 
(secretarial input!).

Garry

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] accounting package

2010-03-18 Thread Garry Saddington
Does anyone know of a web based accounting(finance) package that uses 
Postgresql as a backend?

Thanks Garry

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] windows 7 compatiblity?

2010-04-05 Thread Garry Saddington

Frank Heikens wrote:



Hi

I recently bought Windows 7 32 bit professional.
Unfortunately Postgresql 8.4.3 did not install or work.


Tell us about your problems, error messages and logs, then we can help 
you to get it working.


I started searching Google and found that a lot of other people have 
the same problem.


Many others have it working, but that's normal and that's why they 
didn't post any message on a forum.



Will there be a minor release to fix the problem?


What problem? Tell us about it!


Will it be fixed in the upcoming version 9.0?




I had a problem installing my software (which includes Postgresql) on a 
Windows 7 demo laptop last week. It turned out that accounts that are 
designated as administrator do not have enough privileges to install as 
a service. Without wishing to go delving into the config tools and 
wasting any more time I logged out and then back in using the 
Administrator account that came with W7 (no password - security, what 
security?), ran the setup again and everything worked fine. The services 
were then available to all other accounts.

HTH, just my experience.
Garry





--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] timestamp differences

2008-12-28 Thread Garry Saddington
I have a timestamp column that I want to compare with current timestamp.
I want to get all rows that are less than 10 minutes old. I have searched but 
can not find how to do this, any pointers?
regards
Garry

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] getting dates in the past

2006-09-25 Thread garry saddington
How could I translate this into sql?

select result from results
where date_entered between (last september and the one before that)

Its the part in brackets that has me guessing. I am still experimenting
but any help will be gratefully recieved.
Kind Regards
Garry


---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


[GENERAL] time type strange behaviour

2006-10-10 Thread garry saddington
I have the following table def.


CREATE TABLE periods
(
  periodid serial NOT NULL,
  periodnumber integer NOT NULL,
  periodstart time with time zone,
  periodend time with time zone,
  PRIMARY KEY (periodid)
)

This definition does not insert time zone. If I use without time zone
then the time zone is inserted.
If I input a time like: 01:05 AM then on select I get something like:
1970/01/01 01:05:00:00.
If I use without time zone, then I get the correct date,time and time
zone.
The postgres version is 8.1 and I am using psycopg through Zope.

I have date-style set to 'iso dmy'
What I want is to just have the time inserted. Any ideas?
regards
garry


---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


Re: [GENERAL] time type strange behaviour

2006-10-10 Thread garry saddington
On Tue, 2006-10-10 at 11:58 -0400, Tom Lane wrote:
> garry saddington <[EMAIL PROTECTED]> writes:
> > I have the following table def.
> > CREATE TABLE periods
> > (
> >   periodid serial NOT NULL,
> >   periodnumber integer NOT NULL,
> >   periodstart time with time zone,
> >   periodend time with time zone,
> >   PRIMARY KEY (periodid)
> > )
> 
> > This definition does not insert time zone. If I use without time zone
> > then the time zone is inserted.
> > If I input a time like: 01:05 AM then on select I get something like:
> > 1970/01/01 01:05:00:00.
> 
> Better look again --- if you get that output, the column is most
> certainly not a time column --- it must be timestamp.  Perhaps you
> got confused about which table is which?
> 
>   regards, tom lane
No, there is no confusion, I have dropped it, re-made it and tested it
again, same result. I know it sounds odd but this is what happens!
Garry


---(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


[GENERAL] odd result set

2006-11-16 Thread garry saddington
I have the following result from the sql below. Can anyone help by
explaining why the last record could be returned. Periodstart and
periodend are time data types. I have tried to cast '10.35' to a time
type with the same results.


 Periodid
   Periodnumber
   Periodstart
Periodend
1
1
09:00:00.00
09:35:00.00
2
2
09:35:00.00
09:10:00.00
3
3
10:20:00.00
10:55:00.00
4
4
10:50:00.00
11:30:00.00


SQL used:
select * from periods
where '10:35' > periodstart 

Kind regards
Garry


---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


[GENERAL] build for none standard socket

2006-11-22 Thread garry saddington
I have searched and Googled but can't find how to do a ./configure to
use a different socket than /tmp/.s.PGSQL.5432. It says in the manual
that it can be done but then does not say how.
Anyone done this before?
Regards
Garry 


---(end of broadcast)---
TIP 6: explain analyze is your friend


[GENERAL] None standard install directories

2006-11-22 Thread garry saddington
Thanks to this list I have managed to install into a none standard
location and have the socket where I want it -thanks all. However, now I
am getting a socket.lock as well and my application is getting a
permission denied error on connect, how can I prevent this? I have
checked that all directory permissions are OK.
Regards
Garry


---(end of broadcast)---
TIP 6: explain analyze is your friend


[GENERAL] starting postgres on windows

2006-11-27 Thread garry saddington
How would I start Postgres on windows as an un-privileged user without
logging into an un-privileged account. I have tried the -U switch but it
still complains. I have version 8.
kind regards
Garry


---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


[GENERAL] counting query

2007-01-28 Thread garry saddington
I have a table definition such as:

CREATE TABLE attendance
(
  attendanceid serial primary key,
  entered date DEFAULT current_date NOT NULL,
  absent boolean,
  authorization text default 'N',
  timeperiod char(2) check(timeperiod in('AM','PM')),
  days varchar(10),
  studentid int,
  unique(entered,timeperiod,studentid)
)

Which is used to record school attendance data. I am now trying to write
a query to identify trends in absences by counting the days column and
returning any student that has repeated absences on certain days. I am
struggling to return anything that does not need further manipulation in
Python before being useful.
Does anyone have any ideas?


---(end of broadcast)---
TIP 6: explain analyze is your friend


Re: [GENERAL] counting query

2007-01-28 Thread garry saddington
On Sun, 2007-01-28 at 09:57 -0600, Ron Johnson wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> On 01/28/07 07:05, garry saddington wrote:
> > I have a table definition such as:
> > 
> > CREATE TABLE attendance
> > (
> >   attendanceid serial primary key,
> >   entered date DEFAULT current_date NOT NULL,
> >   absent boolean,
> >   authorization text default 'N',
> >   timeperiod char(2) check(timeperiod in('AM','PM')),
> >   days varchar(10),
> >   studentid int,
> >   unique(entered,timeperiod,studentid)
> > )
> > 
> > Which is used to record school attendance data. I am now trying to write
> > a query to identify trends in absences by counting the days column and
> > returning any student that has repeated absences on certain days. I am
> > struggling to return anything that does not need further manipulation in
> > Python before being useful.
> > Does anyone have any ideas?
> 
> When you say "certain days", you mean "days of the week"?
> 
> If so, create a view like:
> CREATE VIEW V_DAY_ABSENCES AS
> SELECT ENTERED,
>AUTHORIZATION,
>TIMEPERIOD,
>DAYS,
>STUDENTID,
>DOW(CAST(ENTERED AS TIMESTAMP)) AS WEEKDAY
> FROM ATTENDANCE
> WHERE ABSENT = TRUE;
> 
> Then, this query should do what you want:
> SELECT STUDENTID,
>TIMEPERIOD,
>WEEKDAY,
>COUNT(*)
> FROM V_DAY_ABSENSES
> GROUP BY STUDENTID,
>  TIMEPERIOD,
>  WEEKDAY
> HAVING COUNT(*) > 3;
Thank you, this works great. But I have another problem: Is it possible
to identify absences in consecutive weeks on the same day. EG. If a
pupil has a pattern of having every monday AM off school, how could that
be identified?
Regards
Garry


---(end of broadcast)---
TIP 6: explain analyze is your friend


[GENERAL] simplifying SQL

2007-02-07 Thread garry saddington
I have this query which essentially returns records that exist in one
table (studentclass) and not another (effortandattainment) to check when
teachers have entered their student grades.

select
distinct(studentclass.studentclassid),classes.subject,studentclass.studentid as 
classstudent,classes.teacher,students.studentid,students.firstname,students.surname
 
from studentclass left join effortandattainment 
on(effortandattainment.classid=studentclass.classid and
effortandattainment.studentid=studentclass.studentid),students,classes

where students.studentid=studentclass.studentid
and studentclass.classid=classes.classid
and studentclass.classid not in (
select studentclass.classid
from studentclass inner join effortandattainment 
on(effortandattainment.classid=studentclass.classid and
effortandattainment.studentid=studentclass.studentid)
)

I was wondering whether a simpler method exists to do the same thing or
is this OK.
Regards
Garry


---(end of broadcast)---
TIP 6: explain analyze is your friend


[GENERAL] date format

2007-03-04 Thread Garry Saddington
I have 'datestyle ISO,DMY' set in postgresql.conf but the date output is still 
rendered in the format (y,m,d) . How can I change this behaviour? 
regards
garry

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [GENERAL] date format

2007-03-04 Thread Garry Saddington
On Sunday 04 March 2007 15:28, Raymond O'Donnell wrote:
> On 04/03/2007 12:58, Jorge Godoy wrote:
> > Garry Saddington <[EMAIL PROTECTED]> writes:
> >> I have 'datestyle ISO,DMY' set in postgresql.conf but the date output is
> >> still rendered in the format (y,m,d) . How can I change this behaviour?
> >
> > ISO means y-m-d...
>
> The default postgresql.conf that is installed has
>
>datestyle = iso,mdy
>
> though commented out - on a new installation I uncomment this line as a
> matter of course and change it to "iso,dmy" and it works fine.
>
> Are you sure that PostgreSQL is presenting the dates in the wrong
> format? Could there be another layer that's swapping the month and year
> around? - try SELECTing some date values from psql and see what you get.
>
I tried pgAdmin3 on windows to run 'select now()'  and it still does not 
return the correct datestyle.
Regards
Garry


---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [GENERAL] date format

2007-03-04 Thread Garry Saddington
On Sunday 04 March 2007 16:16, Raymond O'Donnell wrote:
> On 04/03/2007 16:16, Garry Saddington wrote:
> > I tried pgAdmin3 on windows to run 'select now()'  and it still does not
> > return the correct datestyle.
>
> Probably a silly question, but did you remember to restart the server
> after changing the datestyle setting?
yes
regards
garry
> Ray.
>
> ---
> Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
> [EMAIL PROTECTED]
> ---
>
> ---(end of broadcast)---
> TIP 5: don't forget to increase your free space map settings

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [GENERAL] date format

2007-03-04 Thread Garry Saddington
On Sunday 04 March 2007 17:09, Martijn van Oosterhout wrote:
> On Sun, Mar 04, 2007 at 05:05:44PM +0000, Garry Saddington wrote:
> > On Sunday 04 March 2007 16:16, Raymond O'Donnell wrote:
> > > On 04/03/2007 16:16, Garry Saddington wrote:
> > > > I tried pgAdmin3 on windows to run 'select now()'  and it still does
> > > > not return the correct datestyle.
> > >
> > > Probably a silly question, but did you remember to restart the server
> > > after changing the datestyle setting?
> >
> > yes
> > regards
>
> Can you show us your exact output so we don't have to guess? I get
> this:
>
> # set datestyle=iso,dmy;
> SET
> # select now();
>   now
> ---
>  2007-03-04 18:07:54.626267+01
> (1 row)
>
> Which is precisely what I expect.
Which is precisely what I get, but I want  04-03-2007.
regards
Garry

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


[GENERAL] delete with self join

2007-04-16 Thread garry saddington
I am trying this syntax which is my interpretation of the docs:

 delete from siblings s1 using siblings s2
WHERE  s1.principal = s2.principal
  and s1.sibling=175

Can anyone tell me where I am going wrong?
regards
Garry


---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [GENERAL] delete with self join

2007-04-17 Thread garry saddington
On Tue, 2007-04-17 at 09:21 +0100, Richard Huxton wrote:
> garry saddington wrote:
> > I am trying this syntax which is my interpretation of the docs:
> > 
> >  delete from siblings s1 using siblings s2
> > WHERE  s1.principal = s2.principal
> >   and s1.sibling=175
> > 
> > Can anyone tell me where I am going wrong?
> 
> 1. What's happening - are you getting an error?
I am getting a syntax error (via psycopg) at or near s1 - perhaps this is a 
psycopg problem?
> 2. What is the query supposed to do? I can't see why you're not just doing:
> DELETE FROM siblings WHERE sibling=175;
> 

I am keeping a record of siblings in a school. The user chooses one
student and there siblings such that id's are entered into a table as
such:
TABLE SIBLINGS:

principal  sibling
  809 234
  809 785
  809 345
  809 809

809 is a sibling of all of them, but of course 234 is a sibling of 785.
To retrieve siblings I use this query:

  SELECT
students.studentid,students.firstname,students.surname,students.year,students.pastoralgroup,students.dob
FROM   siblings c, siblings c2,students
WHERE  c.principal = c2.principal
  and c.sibling=234 (this value is supplied in a variable)
and c2.sibling=students.studentid

What I am trying to do is to allow the user to correct input mistakes by
deleting all the siblings of one family at the same time by choosing
just one of the siblings. I hope this clears things up.
Regards
Garry


---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [GENERAL] delete with self join

2007-04-17 Thread garry saddington
On Tue, 2007-04-17 at 10:15 +0100, Richard Huxton wrote:
> garry saddington wrote:
> > On Tue, 2007-04-17 at 09:21 +0100, Richard Huxton wrote:
> >> garry saddington wrote:
> >>> I am trying this syntax which is my interpretation of the docs:
> >>>
> >>>  delete from siblings s1 using siblings s2
> >>> WHERE  s1.principal = s2.principal
> >>>   and s1.sibling=175
> >>>
> >>> Can anyone tell me where I am going wrong?
> >> 1. What's happening - are you getting an error?
> > I am getting a syntax error (via psycopg) at or near s1 - perhaps this is a 
> > psycopg problem?
> >> 2. What is the query supposed to do? I can't see why you're not just doing:
> >> DELETE FROM siblings WHERE sibling=175;
> >>
> > 
> > I am keeping a record of siblings in a school. The user chooses one
> > student and there siblings such that id's are entered into a table as
> > such:
> > TABLE SIBLINGS:
> > 
> > principal  sibling
> >   809 234
> >   809 785
> >   809 345
> >   809 809
> 
> > What I am trying to do is to allow the user to correct input mistakes by
> > deleting all the siblings of one family at the same time by choosing
> > just one of the siblings. I hope this clears things up.
> 
> Ah, OK. The error then is that you're testing against s1.sibling not 
> s2.sibling. "delete from siblings s1 ... and s1.sibling=175" which means 
> you're not using s2 at all.
> 
> You might find it clearer with a subquery:
> DELETE FROM siblings WHERE principal = (
>   SELECT principal FROM siblings WHERE sibling=234
> );
Thanks, can't think why I went the complicated route!
Regards
Garry


---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


[GENERAL] xml to db converter

2007-05-10 Thread garry saddington
Does anyone know of a tool that will generate a postgres database schema
given an xml schema(xsd). Have tried xmlspy which says it does so but it
only has limited postgres support and then it crashes.
regards
Garry


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

   http://archives.postgresql.org/


[GENERAL] counting days

2006-08-29 Thread garry saddington
I need to count the days between two dates that are not saturdays or
sundays. I have read the manual and searched the lists but I am
struggling. I can count the days but am finding difficulty excluding sat
and sun from the count. I need this without reference to any tables.
Does anyone have any pointers please.
Regards
Garry


---(end of broadcast)---
TIP 6: explain analyze is your friend


[GENERAL] create table as problem

2006-09-15 Thread garry saddington
I am getting a syntax error at or near 'as' in this method, can anyone
help?

create table iclasses
(classid serial,
subject text,
year text,
groups text,
teacher text,
set text
) 
as select distinct subject,year,groups,teacher,set from interimclasses

I need to make a new table with a classid. Any comments are more than
welcome.
regards
garry


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

   http://archives.postgresql.org