[sqlalchemy] Sharding strategy based on primary key

2007-12-01 Thread Simon Wittber
I'd like to set up a sharding strategy where shards are chosen based on this code: SHARD_COUNT = 5 databases = dict((i,create_engine('sqlite://shard_%s.db' % i)) for i in xrange(SHARD_COUNT)) def shard_chooser(mapper, instance, clause=None): return instance.primary_key_id % SHARD_COUNT Ie,

[sqlalchemy] Re: concurent modification

2007-12-01 Thread Michael Bayer
On Dec 1, 7:24 pm, imgrey <[EMAIL PROTECTED]> wrote: > > > OK, i guess you are using the SAVEPOINT then since the postgres docs > > seem to recommend that as a workaround for the transaction abort its > > doing at the IntegrityError point...and the abort is bad for you > > because you want to re

[sqlalchemy] Re: concurent modification

2007-12-01 Thread imgrey
> you should select() for the record first, and if not present, insert() > it. if youre concerned about lots of selects() you can implement a > simple cache in your application, such as a dictionary of ids that > already exist. if theres concern over the cache growing too large, > you can use a

[sqlalchemy] Re: Expire Objects from other Thread

2007-12-01 Thread Koen Bok
Cool, thanks! I got it working pretty wel I think. I replaced the iterator code with a Session.get. Check out the code here: http://paste.pocoo.org/show/13434/ The only thing I am still wondering if Session.get also returns objects in Session.new? Otherwise this won't fix the other bug. I think

[sqlalchemy] Re: Expire Objects from other Thread

2007-12-01 Thread Michael Bayer
On Dec 1, 2007, at 9:33 AM, Koen Bok wrote: > > This is quite hackish, but just an experiment for me. > > We use listen/notify in our app. A seperate thread is listening for > notifications from updated rows in the table. If one is received I'd > like to expire an object in the Session cache so

[sqlalchemy] Re: DateTime vs datetime.datetime

2007-12-01 Thread Samuel
On Nov 30, 11:57 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > 1.2.2 over here produces regular "datetime" objects. Ah, well, thanks for the information. -Samuel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sq

[sqlalchemy] Expire Objects from other Thread

2007-12-01 Thread Koen Bok
This is quite hackish, but just an experiment for me. We use listen/notify in our app. A seperate thread is listening for notifications from updated rows in the table. If one is received I'd like to expire an object in the Session cache so it gets refetched the next time it is accessed. I have it