http://docs.sqlalchemy.org/en/rel_0_8/orm/tutorial.html?highlight=raw%20sql#using-literal-sql
>>> session.query("id", "name", "thenumber12").\
... from_statement("SELECT id, name, 12 as "
... "thenumber12 FROM users where name=:name").\
... params(name='ed').all()
[(1, u'ed', 12)]
There's also a great SqlAlchemy google group.
On Jan 25, 11:20 pm, Vincent Catalano <[email protected]>
wrote:
> Hello pyramid friends,
>
> I am currently using SQLAlchemy for a current pyramid project, however, I
> have come to a point where I need to be able to run some raw Postgres
> queries that have been parameterized (word?).
>
> I have tried the following to no avail:
>
> DBSession().execute(
> ''
> INSERT INTO users(id, user_name)
> VALUES (:id, :user_name)
> ''',
> {
> 'id': 2422,
> 'user_name': 'someguy'
> })
>
> The query appears to work since no error is thrown, however, no data is
> inserted into the database. What is the best way to run parameterized
> queries with SQLAlchemy?
>
> Thanks for your help.
>
> -Vincent
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.