It would be great if somebody could please let me know how to find the id of the last inserted row in a table using DAL
On Fri, Sep 10, 2010 at 4:09 PM, b vivek <bvivek1...@gmail.com> wrote: > Sorry for the late reply Martin, but even if I add the datetime field in > here,and order by the datetime field , wont I get the data > in ascending order . However I did what you had suggested , But i still am > able to retrive the data in ascending order rather than descending. > Could there be any other method .. > (A quick recap--> I am trying to get the data ordered in descending order > from the dbase. It can be done by using a tilde , but the GAE seems to > ignore the tilde all together.. Please help) > > > On Thu, Sep 9, 2010 at 3:46 PM, Martin.Mulone <mulone.mar...@gmail.com>wrote: > >> Yes but i think this is gae thing. You try? with max(id) or add some >> datetime field and order by this field like Field('created_on', >> 'datetime', >> default=datetime.datetime.today(),writable=False,readable=False) >> >> On 9 sep, 03:06, b vivek <bvivek1...@gmail.com> wrote: >> > Ok so if i have a table in my db named homepage as below:- >> > ---------------------- >> > id | data | >> > ----------------------- >> > 1 | vivek| >> > ---------------------- >> > 2 | andrew| >> > ----------------------- >> > >> > Now if I want to retrieve only the last row .. i can do this >> > homepage=db().select(db.homepage.ALL,orderby=~db.homepage.id >> ,limitby=(0,1)) >> > >> > Now let me point out that this works prefectly on localhost using the >> normal >> > rdbms like mysql or sqlite. However when I use the local development GAE >> > environ or even when I upload it to GAE,it just returns the first row. >> Seems >> > like it totally ignores the tilde. >> > >> > The same command when used on GAE gives me the first row,rather than the >> > last one. >> > >> > Thanks >> > Vivek >> > >> > On Thu, Sep 9, 2010 at 11:27 AM, Andrew Thompson <andre...@aktzero.com >> >wrote: >> > >> > >> > >> > > On 9/9/2010 12:24 AM, b vivek wrote: >> > >> > > Hi I wanted to retrieve the latest data entered in a table and thus >> used >> > > the below syntax for data look up >> > >> > > homepage=db().select(db.homepage.ALL,orderby=~db.homepage.id >> > > ,limitby=(0,1)) >> > >> > > This is expected to retrieve the last row entered in the table >> homepage . >> > > While this works perfectly, it does not work on GAE. It would be >> really >> > > helpful, if someone could please help me with this.. >> > >> > > While I'm not familiar with GAE, I can say for sure that you've not >> > > provided enough information. >> > >> > > How does it "not work"? >> > >> > > For example, can you make any .select() work? If you remove the >> orderby or >> > > the limitby does it change how it doesn't work? >> > >> > > -- >> > > Andrew Thompsonhttp://aktzero.com/ >> > >