I am wondering if this is a bug in my reasoning, or in SQLAlchemy
(0.5.3). I have a model which is pretty simple:

class ClothingArticle(BaseObject):
    __tablename__ = "clothing_article"

    id = schema.Column(types.Integer(), primary_key=True, autoincrement=True)
    currency = schema.Column(types.String(3),
            nullable=False, default="EUR", index=True)
    price = schema.Column(types.Numeric(precision=6, scale=2),
        nullable=False)
    price_euro = schema.Column(types.Numeric(precision=6, scale=2),
        nullable=False, index=True)


When a currerency rate changes I am trying to update it, using a simple
prepared statement:

   update=ClothingArticle.__table__.update().\
           where(ClothingArticle.currency==sql.bindparam("currency")).\
           
values(dict(price_euro=ClothingArticle.price*sql.bindparam("newrate")))

The statement is processed correctly:

(Pdb) print update
UPDATE clothing_article SET price_euro=(clothing_article.price * :newrate) 
WHERE clothing_article.currency = :currency

But when I try to use it:

   session.execute(update, currency=currency["code"], newrate=newrate)

I get an error:

    TypeError: "get_bind() got an unexpected keyword argument 'currency'"

I find it hard to believe parameter binding does not work, since SA uses
that internally, but I also can't spot my mistake unfortunately.

Wichert.

-- 
Wichert Akkerman <wich...@wiggy.net>    It is simple to make things.
http://www.wiggy.net/                   It is hard to make things simple.

--~--~---------~--~----~------------~-------~--~----~
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