Re: problem with invalid characters

Timothy Smith <timothy-/[email protected]> Thu, 13 Jan 2005 10:51:51 +1000
Newsgroups gmane.comp.python.db.pypgsql.user
Message-ID <[email protected]>
Karsten Hilbert wrote:

>>>>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
>  
>
your right, it needed '%s'


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