MysqlDB uses "format" style bind parameters, i.e. "%s".  if youd like  
SQLAlchemy to convert ":c1" to an appropriate bind param for MySQL,  
use c.execute(text('select * from t_test where c1=:c1'), {'c1':1}).

On Nov 9, 2007, at 6:56 AM, Bruza wrote:

>
> This is driving me nuts... The very very simple SQL query below using
> ":parameter"
> always gives me syntax error. However, the same query using constant
> '1' then it
> works fine. I hope this is not because some stupid mistake I made at
> 4:00 AM...
>
> Can anybody help?
>
> Thanks,
>
> Ben
>
>>>> c.execute('select * from t_test where c1=:c1', {'c1':1})
> 2007-11-09 04:53:34,953 INFO sqlalchemy.engine.base.Engine.0x..10
> select * from
> t_test where c1=:c1
> 2007-11-09 04:53:34,953 INFO sqlalchemy.engine.base.Engine.0x..10
> {'c1': 1}
> Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>  File "C:\utils\Python24\lib\site-packages\sqlalchemy-0.4.0-py2.4.egg
> \sqlalchem
> y\orm\session.py", line 527, in execute
>    return self.__connection(engine,
> close_with_result=True).execute(clause, par
> ams or {}, **kwargs)
>  File "C:\utils\Python24\lib\site-packages\sqlalchemy-0.4.0-py2.4.egg
> \sqlalchem
> y\engine\base.py", line 779, in execute
>    return Connection.executors[c](self, object, multiparams, params)
>  File "C:\utils\Python24\lib\site-packages\sqlalchemy-0.4.0-py2.4.egg
> \sqlalchem
> y\engine\base.py", line 789, in _execute_text
>    self.__execute_raw(context)
>  File "C:\utils\Python24\lib\site-packages\sqlalchemy-0.4.0-py2.4.egg
> \sqlalchem
> y\engine\base.py", line 852, in __execute_raw
>    self._cursor_execute(context.cursor, context.statement,
> context.parameters[0
> ], context=context)
>  File "C:\utils\Python24\lib\site-packages\sqlalchemy-0.4.0-py2.4.egg
> \sqlalchem
> y\engine\base.py", line 869, in _cursor_execute
>    raise exceptions.DBAPIError.instance(statement, parameters, e)
> sqlalchemy.exceptions.ProgrammingError: (ProgrammingError) (1064, "You
> have an e
> rror in your SQL syntax; check the manual that corresponds to your
> MySQL server
> version for the right syntax to use near ':c1' at line 1") 'select *
> from t_test
> where c1=:c1' {'c1': 1}
>>>> c.execute('select * from t_test where c1=1')
> 2007-11-09 04:53:44,515 INFO sqlalchemy.engine.base.Engine.0x..10
> select * from
> t_test where c1=1
> 2007-11-09 04:53:44,515 INFO sqlalchemy.engine.base.Engine.0x..10 {}
> <sqlalchemy.engine.base.ResultProxy object at 0x00AEE110>
>>>>
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to