Re: Error in PostgreSQL query with psycopg

From: Douglas Horst <horstinfo(at)comcast(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Error in PostgreSQL query with psycopg
Date: 2006-07-31 17:40:11
Message-ID: 44CE407B.4070709@comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Parthan wrote:
> Hello,
>
> Am not sure whether i can post such a question over here, still the
> error is in my postgresql query syntax, hence i post it in this
> mailing list. sorry if am wrong.
>
> I am getting a 'type error' with the following query.
>
> [Code]
>
> Line68:
> query = cursor.execute("""INSERT INTO ConfMain (ConfName, ConfHost,
> ConfStart, ConfEnd, ConfDays, ConfStartTime, ConfEndTime, ConfSize)
> VALUES (\'%s\', \'%s\', \'%%\', \'%%\', %i, \'%%\', \'%%\', %i);""" %
> (conf_name, host_name, start_day, end_day, int(num_days), start_time,
> end_time, aud_size))
Try a newline at the end of the query as :

query = cursor.execute("""INSERT INTO ConfMain (ConfName, ConfHost,
ConfStart, ConfEnd, ConfDays, ConfStartTime, ConfEndTime, ConfSize)
VALUES (\'%s\', \'%s\', \'%%\', \'%%\', %i, \'%%\', \'%%\', %i);\n""" %
(conf_name, host_name, start_day, end_day, int(num_days), start_time,
end_time, aud_size))

I don't remember if it is necessary or not but I've been making it a
habit of using line continuation if it is a multi-line query

D. C. Horst
Evanston, IL.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2006-07-31 17:41:02 Re: Postgres on 64bit Windows Server with WOW64
Previous Message David Jorjoliani 2006-07-31 17:34:08 Unicode sorting problem