title: PostgreSQL - how to run VACUUM from code outside transaction block?
body: <p>I am using Python with psycopg2 and I'm trying to run a full <code>VACUUM</code> after a daily operation which inserts several thousand rows.  The problem is that when I try to run the <code>VACUUM</code> command within my code I get the following error:</p>
  
  <pre><code>psycopg2.InternalError: VACUUM cannot run inside a transaction block
  </code></pre>
  
  <p>How do I run this from the code outside a transaction block?</p>
  
  <p>If it makes a difference, I have a simple DB abstraction class, a subset of which is displayed below for context (not runnable, exception-handling and docstrings omitted and line spanning adjustments made):</p>
  
  <pre><code>class db(object):
      def __init__(dbname, host, port, user, password):
          self.conn = psycopg2.connect("dbname=%s host=%s port=%s \
                                        user=%s password=%s" \
                                        % (dbname, host, port, user, password))
  
          self.cursor = self.conn.cursor()
  
      def _doQuery(self, query):
          self.cursor.execute(query)
          self.conn.commit()
  
      def vacuum(self):
          query = "VACUUM FULL"
          self._doQuery(query)
  </code></pre>