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