Exception: "VACUUM cannot run inside a BEGIN/END block"

Rene Pijlman <[email protected]> Sat, 29 Nov 2003 17:37:20 +0100
Newsgroups gmane.comp.python.db.pypgsql.user
Organization the arrangement of parts so as to form an effective whole
Message-ID <[email protected]>
Hello,

When I try to issue the statement "vacuum analyze" I get an
exception with the error message "VACUUM cannot run inside a
BEGIN/END block".

This is the code that reproduces the problem:

from pyPgSQL import PgSQL
db = PgSQL.connect(host="myhost", database="mydb",
                   user="myuser", password="mypw")
cursor = db.cursor()
cursor.execute("vacuum analyze")

I use pyPgSQL version 2.4 with Python 2.2 on Windows XP. The
server is PostgreSQL 7.2.1 on Linux.

Is this considered a bug in pyPgSQL? Is there any way to issue
"vacuum analyze" from within a Python program?

The reason I'm doing this is that my program inserts and deletes
lots of records. And the PostgreSQL manual says: "After adding
or deleting a large number of records, it may be a good idea to
issue a VACUUM ANALYZE command for the affected table. This will
update the system catalogs with the results of all recent
changes, and allow the PostgreSQL query optimizer to make better
choices in planning user queries."

Thanks in advance for your help.

-- 
Regards / Groeten,  http://www.leren.nl
René Pijlman        http://www.applinet.nl
  


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/