title: REINDEX DATABASE cannot run inside a transaction block
body: <p>I am using an old version of sqlalchemy (0.8) and I need to execute "<code>REINDEX DATABASE &lt;dbname&gt;</code>" on <strong>PostgreSQLql 9.4</strong> by using sqlalchemy api.</p>
  
  <p>Initially I tried with:</p>
  
  <pre><code>conn = pg_db.connect()  
  conn.execute('REINDEX DATABASE sg2')
  conn.close()
  </code></pre>
  
  <p>but I got error "<code>REINDEX DATABASE cannot run inside a transaction block</code>".</p>
  
  <p>I read in internet and tried other changes:</p>
  
  <pre><code>engine.execute(text("REINDEX DATABASE sg2").execution_options(autocommit=True))
  </code></pre>
  
  <p>(I tried also with autocommit=False).</p>
  
  <p>and</p>
  
  <pre><code>conn = engine.raw_connection()  
  cursor = conn.cursor()
  cursor.execute('REINDEX DATABASE sg2')
  cursor.close()
  </code></pre>
  
  <p>I always have the same error.</p>
  
  <p>I tried also following:</p>
  
  <pre><code>conn.execution_options(isolation_level="AUTOCOMMIT").execute(query)
  </code></pre>
  
  <p>but I got error
   Invalid value 'AUTOCOMMIT' for isolation_level. Valid isolation levels for postgresql are REPEATABLE READ, READ COMMITTED, READ UNCOMMITTED, SERIALIZABLE</p>
  
  <p>What am I missing here ? Thanks for any help.</p>