Sriram, I just noticed this thread. What you are seeking is fairly trivial once 
you figure out SQLAlchemy a little better.

Here is how I implemented container-unique incrementing ids:

https://github.com/hasgeek/coaster/blob/master/coaster/sqlalchemy.py#L197

The trick is to override __init__ and set the value of the column to an SQL 
expression that is evaluated database-side on commit. In my case, I'm checking 
for the max value from existing instances that share the same parent. In your 
case, it'll be instances that share the same date.

Kiran 

-- 
Kiran Jonnalagadda
http://jace.zaiki.in/
http://hasgeek.com/


On Tuesday, 12 February 2013 at 2:02 PM, Sriram Karra wrote:

> On Tue, Feb 12, 2013 at 12:32 PM, Dhruv Baldawa <dhruvbald...@gmail.com 
> (mailto:dhruvbald...@gmail.com)>wrote:
> 
> > Then I guess you are doing it the wrong way. You should only have a single
> > session object (unless working with multiple databases simultaneously). The
> > object should be binded with whatever connection is required.
> > 
> 
> 
> 
> 
> I do have two separate databases - a demo database for training purposes
> and a live production database. Both have to be functional and available
> simultaneously.
> 
> Anyway, thanks for your help. I was only trying to figure out some way of
> achieving what I wanted without accessing the session object. I guess
> that's not possible. Good to know that.
> 
> Cheers,
> Karra
> _______________________________________________
> BangPypers mailing list
> BangPypers@python.org (mailto:BangPypers@python.org)
> http://mail.python.org/mailman/listinfo/bangpypers
> 
> 


_______________________________________________
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers

Reply via email to