Or in one line ;-)

def deleteRecords(): [db[tbl].truncate() for tbl in db.tables if not
tbl.startswith('auth_') and not tbl in
('local__user','local_history')]

On Apr 29, 12:43 am, mart <[email protected]> wrote:
> yup, that did it! AND... only those tables not in _tables! this is
> great! Thanks Massimo! :)
>
> Mart :)
>
> if anyone interested, this empties tables NOT specified in a list:
>
> def deleteRecords():
>     _tables=['auth_user',
>                 'auth_group',
>                     'auth_membership',
>                         'auth_permisssion',
>                             'auth_event',
>                                 'local_user',
>                                     'local_history']
>     for tbl in db.tables:
>         if not tbl in _tables:emptyTable(tbl)
>
> def emptyTable(tbl):
>     for mTbl in db.tables:
>         if tbl in mTbl:
>             if mTbl.startswith(tbl):db[tbl].truncate()
>
> On Apr 29, 12:12 am, Massimo Di Pierro <[email protected]>
> wrote:
>
>
>
>
>
>
>
> > Instead of
>
> > db(db[tbl].id>0).delete()
>
> > you can use
>
> > db[tbl].truncate()
>
> > which is faster but does not work on GAE.
>
> > On Apr 28, 8:18 pm, mart <[email protected]> wrote:
>
> > > Hi,
>
> > >  I'm thinking this should work... its done through script. Should I be
> > > doing it differently?
>
> > > thanks,
> > > Mart :)
>
> > > def deleteRecords():
> > >     _tables=['auth_user',
> > >                         'auth_group',
> > >                             'auth_membership',
> > >                                 'auth_permisssion',
> > >                                     'auth_event',
> > >                                         'local_user',
> > >                                             'local_history']
> > >     for tbl in db.tables:
> > >         if not tbl in _tables:
> > >             db(db[tbl].id>0).delete()

Reply via email to