I see, apparently I'm a jackass. My 'fix' breaks everything else
because... if I pass an int as a value I get 4L instead of 4 in the
SQL query.
Before I keep screwing around with the db.py code I'll wait to hear
from you guys about the problem I've run into, there's probably a very
obvious explanation and workaround.
On Dec 11, 2007 10:46 PM, Hermann Kaser <[EMAIL PROTECTED]> wrote:
> Hello,
>
> The following query is giving me errors:
>
> web.insert('updates', seqname=id, start=web.SQLLiteral('NOW()'))
>
> When I run it I get:
>
> /usr/lib/python2.5/site-packages/web/db.py:340: Warning: Data
> truncated for column 'start' at row 1
>
> and the 'start' column in the database will be set to '0000-00-00
> 00:00:00'. But when if I do _test=True I get the correct query:
>
> INSERT INTO updates (start) VALUES (NOW())
>
> If I go to db.py and output the query right before it gets executed I get
>
> sql_query.s => INSERT INTO updates (start) VALUES (%s)
> sql_query.v => (NOW(),)
>
> I've looked at the code and what happens is that the cursor recieves
> the string and arguments for it to format rather than the already
> formatted string by SQLQuery. I fixed it by changing line 338 from
>
> out = cur.execute(sql_query.s, sql_query.v)
>
> to
>
> out = cur.execute(str(sql_query))
>
> Let me know if the old behaviour was on purpose.
>
> Regards,
> Hermann Käser
> http://theragingche.com/
> http://semicir.cl/user/hermzz
>
--
Hermann Käser
http://theragingche.com/
http://semicir.cl/user/hermzz
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---