<br><br><div class="gmail_quote">On Fri, May 29, 2009 at 3:21 PM, Dennis Lee Bieber <span dir="ltr"><<a href="mailto:wlfraed@ix.netcom.com">wlfraed@ix.netcom.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
This won't work as the DB-API is going to quote the parameter, and<br>
the final result would be '%'whatever'%'. Essentially, you must put the<br>
wildcard marker on the actual parameter before feeding it to the API.<br>
--<br>
Wulfraed Dennis Lee Bieber KD6MOG<br>
<a href="mailto:wlfraed@ix.netcom.com">wlfraed@ix.netcom.com</a> <a href="mailto:wulfraed@bestiaria.com">wulfraed@bestiaria.com</a><br>
<a href="HTTP://wlfraed.home.netcom.com/" target="_blank">HTTP://wlfraed.home.netcom.com/</a><br>
(Bestiaria Support Staff: <a href="mailto:web-asst@bestiaria.com">web-asst@bestiaria.com</a>)<br>
<a href="HTTP://www.bestiaria.com/" target="_blank">HTTP://www.bestiaria.com/</a><br>
<font color="#888888"><br>
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br><div><br></div><div>it works for me :)</div><div><div><br></div><div><div>mysql> select * from test_table ;</div><div>+------+------+------+</div><div>| a | b | c |</div><div>+------+------+------+</div>
<div>| 0 | 0 | 0 | </div><div>| 1 | 1 | 1 | </div><div>| 2 | 2 | 2 | </div><div>| 3 | 3 | 3 | </div><div>| 4 | 4 | 4 | </div><div>| 5 | 5 | 5 | </div><div>| 6 | 6 | 6 | </div>
<div>| 7 | 7 | 7 | </div><div>| 8 | 8 | 8 | </div><div>| 9 | 9 | 9 | </div><div>| 10 | 10 | 10 | </div><div>| 11 | 11 | 11 | </div><div>| 12 | 12 | 12 | </div><div>| 13 | 13 | 13 | </div>
<div>| 14 | 14 | 14 | </div><div>| 15 | 15 | 15 | </div><div>| 16 | 16 | 16 | </div><div>| 17 | 17 | 17 | </div><div>| 18 | 18 | 18 | </div><div>| 19 | 19 | 19 | </div><div>| 20 | 20 | 20 | </div>
<div>| 21 | 21 | 21 | </div><div>| 22 | 22 | 22 | </div><div>| 23 | 23 | 23 | </div><div>| 24 | 24 | 24 | </div><div>| 25 | 25 | 25 | </div><div>| 26 | 26 | 26 | </div><div>| 27 | 27 | 27 | </div>
<div>| 28 | 28 | 28 | </div><div>| 29 | 29 | 29 | </div><div>+------+------+------+</div><div>30 rows in set (0.00 sec)</div></div><div><br></div><div><br></div><div>>>> import MySQLdb</div><div>>>> conn = MySQLdb.connect (host='localhost', user='root', passwd='crappy', db='testme')</div>
<div>>>> input_crap = "0"</div><div>>>> conn.query("select * from test_table where a like '%%%s%%'" %input_crap)</div><div>>>> result = conn.store_result()</div><div>
>>> rows = result.num_rows() </div><div>>>> cols = result.num_fields()</div><div>>>> data = result.fetch_row(rows,1) </div><div>>>> print data</div><div>({'a': '0', 'c': '0', 'b': '0'}, {'a': '10', 'c': '10', 'b': '10'}, {'a': '20', 'c': '20', 'b': '20'})</div>
<div>>>> </div><div><br></div></div><div>HTH</div><div><br></div>