Hi,

I'm trying to use MySQL's full text search in my app and to do that
I'm setting up a custom WHERE clause using bind parameters.

I'm not sure if I'm doing something wrong, but using bind parameters
everything *almost* works.

I tested this with the example from MySQL's docs[1].  I've set up the
table definition (didn't get as far as a mapper yet, but it's not
needed at the moment) and here's the result:

>>> ft_search = article_table.select("MATCH (title,body) AGAINST (':q')")
>>> ft_search.execute(q="database")
[2006-10-18 17:43:02,911] [engine]: SELECT articles.id,
articles.title, articles.body
FROM articles
WHERE MATCH (title,body) AGAINST ('%s')
[2006-10-18 17:43:02,912] [engine]: ['database']
[2006-10-18 17:43:02,914] [engine]: ROLLBACK
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "build/bdist.darwin-8.7.1-Power_Macintosh/egg/sqlalchemy/sql.py",
line 509, in execute
  File "build/bdist.darwin-8.7.1-Power_Macintosh/egg/sqlalchemy/sql.py",
line 463, in execute_using
  File "build/bdist.darwin-8.7.1-Power_Macintosh/egg/sqlalchemy/sql.py",
line 375, in execute
  File "build/bdist.darwin-8.7.1-Power_Macintosh/egg/sqlalchemy/engine/base.py",
line 467, in execute_compiled
  File "build/bdist.darwin-8.7.1-Power_Macintosh/egg/sqlalchemy/engine/base.py",
line 284, in execute_compiled
  File "build/bdist.darwin-8.7.1-Power_Macintosh/egg/sqlalchemy/engine/base.py",
line 280, in proxy
  File "build/bdist.darwin-8.7.1-Power_Macintosh/egg/sqlalchemy/engine/base.py",
line 319, in _execute_raw
  File "build/bdist.darwin-8.7.1-Power_Macintosh/egg/sqlalchemy/engine/base.py",
line 338, in _execute
sqlalchemy.exceptions.SQLError: (ProgrammingError) (1064, "You have an
error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near 'database'')' at
line 3") "SELECT articles.id, articles.title, articles.body \nFROM
articles \nWHERE MATCH (title,body) AGAINST ('%s')" ['database']
>>>

As I say, it's almost working.  The query is right, the substitution
just doesn't seem to be getting made before it's shunted off to MySQL
for execution.

Am I using bind parameters in the wrong way or have I stumbled over a bug?

Thanks in advance,

Lee


[1]: http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html

-- 
Lee McFadden

blog: http://www.splee.co.uk
work: http://fireflisystems.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" 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/sqlalchemy
-~----------~----~----~----~------~----~------~--~---

Reply via email to