Posts

Showing posts from December, 2013

Sequence concept implementation in mongo using pymongo & python

Sequence concept implementation in mongo using pymongo & python import pymongo # define the function that able to generate sequence number def getNextSequence(seq_name):     connection = pymongo.Connection("mongodb://localhost",                                     safe=True)        db = connection.test     sequence = db.sequences     sequencenext = sequence.find_and_modify(query={'seq_name':seq_name},                                        update={'$inc':{'sequence':1}},                                        upsert=True, new=True     sequenceno = sequencenext['sequence']     return sequenceno # Return sequence number for "Student" Table print getNextSequence('student') print getNextSequence('student') You can use above concept same as sequence concept in oracle db and maintain the your own unique key for your own table. You can use this generate sequence value instead of auto generation value for