Hi All,

I need a last push....and I hope someone here in SQLAlcheny cab give me some.

My application uses elixir on a sqlite database.

I Have a table Person with a field birthdate, now I want to sort on the month of this field.

From examples and a lot of peeking I have worked out how to add Userdefined functions.


    session.bind = metadata.bind

    def monthfrom(date):
        return datetime.strptime(date, '%Y-%m-%d %H:%M:%S').month

    con = session.bind.connect().connection
    con.create_function("monthfrom", 1, monthfrom)

but now come the part I have made very little progress on.


personslist=Person.query.filter(Person.birthdate!=None).order_by("func.monthfrom(:date)", {"date": datetime(2000, 1, 2, 0, 0, 0), })

I get an SQLAlchemy.exc.OperationalError

Thanks.


Frans.

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