The view can't have bind parameters, so in your expression you can't use 
literals that are coerced to binds directly, in this case '20101211'.   Feed 
the string expression into a construct like sqlalchemy.literal_column() so that 
it renders inline, literal_column("'20101211'").



On Feb 23, 2011, at 9:11 AM, bool wrote:

> I am unable to create a view if I put a where condition See below for
> error. However I am able to create a view if I do not have a where
> condition. Any idea why this restriction is posed by Sql Alchemy?
> 
> =====================================================================
> mySelect = select([table], table.c.vt_start == '20101211')
> engine.execute("CREATE TEMP VIEW myview AS %s" %
> mySelect.compile(engine));
> ==================================================================
> 
> 
> Stack Trace:
> =========
> 
>    engine.execute("CREATE TEMP VIEW myview AS %s" %
> mySelect.compile(engine));
>  File "/prod/tools/infra/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/engine/
> base.py", line 824, in execute
>    return Connection.executors[c](self, object, multiparams, params)
>  File "/prod/tools/infra/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/engine/
> base.py", line 888, in _execute_text
>    return self.__execute_context(context)
>  File "/prod/tools/infra/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/engine/
> base.py", line 896, in __execute_context
>    self._cursor_execute(context.cursor, context.statement,
> context.parameters[0], context=context)
>  File "/prod/tools/infra/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/engine/
> base.py", line 950, in _cursor_execute
>    self._handle_dbapi_exception(e, statement, parameters, cursor,
> context)
>  File "/prod/tools/infra/SQLAlchemy-0.5.5-py2.5.egg/sqlalchemy/engine/
> base.py", line 931, in _handle_dbapi_exception
>    raise exc.DBAPIError.instance(statement, parameters, e,
> connection_invalidated=is_disconnect)
> sqlalchemy.exc.OperationalError: (OperationalError) parameters are not
> allowed in views 'CREATE TEMP VIEW myview AS SELECT eee.z,
> eee.tt_start, eee.tt_end, eee.vt_start, eee.vt_end \nFROM eee \nWHERE
> eee.vt_start = ?' ()
> 
> -- 
> 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 
> sqlalchemy+unsubscr...@googlegroups.com.
> 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 sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to