[sqlalchemy] Last 2 versions query

2016-06-17 Thread Tim Burgess
I have some working SQL that gets the last two id's (autoincremented) in a TaskRevisons table that has a column that maps to an id in a Tasks table. The SQL is: select task_id, id from TaskRevisions where ( select count(*) from TaskRevisions as t where t.task_id = TaskRevisions.task_id and

[sqlalchemy] Nonefy arguments

2016-06-17 Thread fer mario
Hello Guys, I was having issues cause some empty arguments were treated as "" (emtpy) instead of none, so the filter() was translating the query as 'where column=""' instead of "where column is NULL", so I'm trying to write some validation in my add method in my classes: class

Re: [sqlalchemy] Force type conversions in newly created Declarative objects

2016-06-17 Thread Chuck Bearden
On Friday, June 17, 2016 at 12:14:05 PM UTC-5, Mike Bayer wrote: > > > > On 06/17/2016 12:44 PM, Chuck Bearden wrote: > > I'm using SQLAlchemy 1.0.13 with Python 2.7.10. > > > > I load much of my data naively from text files, which means that for > > newly-created Declarative objects, all the

Re: [sqlalchemy] Force type conversions in newly created Declarative objects

2016-06-17 Thread Jonathan Vanasco
On Friday, June 17, 2016 at 1:14:05 PM UTC-4, Mike Bayer wrote: > > seems appropriate for a basic validator: > > > http://docs.sqlalchemy.org/en/rel_1_0/orm/mapped_attributes.html?highlight=validates#simple-validators > > > There's also the 'descriptor' pattern (on the same page as the

Re: [sqlalchemy] Force type conversions in newly created Declarative objects

2016-06-17 Thread Mike Bayer
On 06/17/2016 12:44 PM, Chuck Bearden wrote: I'm using SQLAlchemy 1.0.13 with Python 2.7.10. I load much of my data naively from text files, which means that for newly-created Declarative objects, all the values are strings, whatever the declared column type: | fromsqlalchemy.ext.declarative

[sqlalchemy] Force type conversions in newly created Declarative objects

2016-06-17 Thread Chuck Bearden
I'm using SQLAlchemy 1.0.13 with Python 2.7.10. I load much of my data naively from text files, which means that for newly-created Declarative objects, all the values are strings, whatever the declared column type: from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import