Re: problem with invalid characters
Karsten Hilbert <[email protected]> Thu, 13 Jan 2005 00:43:14 +0100
| Newsgroups | gmane.comp.python.db.pypgsql.user |
|---|---|
| Message-ID | <[email protected]> |
> >>i'm wondering why i get the following error witht he code below
> >>i'm guessing it's probably somethign very simple i'm goign wrong, most
> >>likely to do with my new line escapes \
> >>if there is a better way of formatting my query to fix this i'm all ears.
> >>
> >>
> >consider using
> >
> >query = """
> >... any formatting you want
> >"""
> >
> >No \ needed.
> >
> >Karsten
> >
> >
> ok i did that b ut i still get the error
>
> cur.execute("""CREATE OR REPLACE FUNCTION week_num ( date )
> File "/usr/local/lib/python2.3/site-packages/pyPgSQL/PgSQL.py", line
> 3072, in execute
> raise OperationalError, msg
> libpq.OperationalError: ERROR: syntax error at or near "20040701" at
> character 92
The error seems to be in the first function declaration. In
there you have the %s *inside* the actual function body. I
doubt that pyPgSQL knows about the proper quoting rules for
that case, eg quotes need to be doubled at least, even tripled
or quadrupled in some special cases.
Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt