[Tutor] insert in postgresql

Jorge Godoy godoy at metalab.unc.edu
Wed Oct 1 11:49:49 EDT 2003


"ajstec" <ajstec at bol.com.br> writes:

> Hi all,
>
>     I am using pypgsql, and try :
>
>>>> a='cat'
>>>> b='dog'
>>>> db.query("insert into curso values
> (default,"%(a)","%(b)")")
> SyntaxError: invalid syntax
>
> Howto ?
>
> Ité (Bye) !

Olá Adilton. :-) Muito calor por aí?


You statement is wrong 'cause you're mixing the quotes.

Try it like that:

db.query("insert into curso values (default, %s, %s)" % (a, b))

If I got it correctly and 'default' is also a value and not a variable
name. 


See you,
-- 
Godoy.     <godoy at metalab.unc.edu>



More information about the Tutor mailing list