2007/3/7, Christoph Zwerschke <[EMAIL PROTECTED]>:
> Jonathan Schaeffer wrote:
> > I have an error while using the delete method on a table. The code is
> > quite simple, delete a row which I got through a SELECT query.
> >
> > table=billinginfo
> > for row in result.dictresult():
> > db.delete(table, row)
> >
> > The python error is :
> > ...
> > KeyError: 'oid(public.billinginfo)'
>
> The delete method is actually intended for deleting a (single) row that
> has been retrieved with the get() method.
This is the part which I didn't get. Thank you.
> The get() method injects the
> oid with the key name oid(public.billinginfo) into the dictionary. If
> you want to use dictresult, you need to do add the oid manually:
>
> result = db.query('select oid as "oid(public.table_name)",* from
> table_name').dictresult()
>
> > Can I expect the delete method to be quicker than doing a query "DELETE
> > FROM " ?
>
> No. db.query("delete from table_name") is the fastest way if you want to
> delete every row in the table. If there are no foreign keys involved,
> you can do it even faster with db.query("truncate table_name").
I'll give this a try.
Thank you.
Jonathan
_______________________________________________
PyGreSQL mailing list
[email protected]
http://mailman.vex.net/mailman/listinfo/pygresql