MySQLDB - generating "...not in (1,2,3)" from Python list ?

bobb rawbobb at hotmail.com
Sat Feb 28 22:56:31 EST 2004


"Richard Shea" <richardshea at fastmail.fm> wrote in message
news:282f826a.0402260128.4400d7d9 at posting.google.com...
> Hi - I'm sorry I haven't responded before I got a cold earlier this
> week and it's kind of knocked me sideways. Reading the replies I
> realised I had done something fundamentally wrong and I was able to
> use them as a basis for getting it to work correctly so thanks very
> much to all of you for your help.
>
> There is one thing about the whole business which I find a bit
> difficult - it would be nice if after you have executed the query you
> were able to actually view the query (with substituted parameters) as
> a string to ensure that your query was what it thought it was. I
> understand that mySQLdb is really a wrapper around the C API for
> MySQL. I've taken a look at that and I can't find anything like what
> I'm describing but if any of you guys do know of such a feature it
> would be useful in future to know - one of the reaons I was having
> problems this time was fully appreciating just what the query was I
> was submitting.
>
Like this?

 print "delete from " + str(t) + " where " + str(col) + " = " +str(num) +
";"
delete from table where id = 1;
???

> I should just say before you think I'm nuts that the 'real' query was
> a good deal more complex (and had more substituted parameters) than
> the simple one which I created to ask the question I did.
>
> Anyway thanks again for all your help.
>
> regards
>
> richard shea.





More information about the Python-list mailing list