JZ wrote:
>
> using sqlalchemy 0.5.8, mysql 5.1
>
> sql = text('select count(*) from :table)
> db.execute(sql, params=dict(table='mytable'))
>
> Results in:
> sqlalchemy.exc.ProgrammingError: (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 ''mytable'' at
> line 1") u'select count(*) from %s' ['mytable']
>
> Is mytable being (single) quoted?
>
> How to properly invoke text() for this case?

bind parameters are not intended to modify the structure of a SQL
statement, only to inject literal values.  the table you're selecting from
is part of the statement's structure.  In this case it's the DBAPI
misinterpreting what you're sending, not SQLAlchemy.  Other database
platforms would reject such a statement in any case.





>
> Thanks.
>
> --
> 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?hl=en.
>
>

-- 
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?hl=en.

Reply via email to