Ability to get a bare cursor
Peewee does not alter the isolation level of the postgres connection, unfortunately the `autocommit` parameter is poorly named. When True, it means basically: "pass queries through the DB-API driver normally and call connection.commit() afterwards". If False, then you need to call commit() yourself.

Working with the psycopg2 connection seems like the best route, since you need to set the connection's isolation level. I think psycopg2 issues an implicit `BEGIN` when you are not in autocommit mode, so that may be what's causing the trouble.
 For now I think it will suffice to leave the `autocommit` semantics as they are. There's quite a bit that's confusing given that postgres itself specifies AUTOCOMMIT differently than the DB-API 2.0, and peewee having it's own definition certainly adds to the confusion.

The code you have there looks good to me, so I'm going to close this.

Hello.

I'm trying to get a bare, out of transaction context cursor from within peewee, but for some reason this does not work for me.

``` python
from peewee import *

database = PostgresqlDatabase('test')

database.set_autocommit(False)
database.execute_sql('VACUUM FULL', require_commit=False)
database.set_autocommit(True)
```

I get 

``` python
Traceback (most recent call last):
  File "autocommit.py", line 9, in <module>
    database.execute_sql('VACUUM FULL', require_commit=False)
  File "/usr/local/lib/python2.7/site-packages/peewee.py", line 3015, in execute_sql
    self.commit()
  File "/usr/local/lib/python2.7/site-packages/peewee.py", line 2864, in __exit__
    reraise(new_type, new_type(*exc_value.args), traceback)
  File "/usr/local/lib/python2.7/site-packages/peewee.py", line 3007, in execute_sql
    cursor.execute(sql, params or ())
peewee.InternalError: VACUUM cannot run inside a transaction block
```

Any chance I'm doing this wrong (should not `set_autocommit` take care of that)?

The only one way I found to do this type of query is by operating low level cursor like this:

``` python
@contextlib.contextmanager
def get_bare_cursor(db):
    """Gets the bare cursor which has no transaction context."""
    connection = db.get_conn()
    old_isolation_level = connection.isolation_level

    connection.set_isolation_level(
        psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
    try:
        yield db.get_cursor()
    finally:
        connection.set_isolation_level(old_isolation_level)

with get_bare_cursor(database) as cursor:
    cursor.execute('VACUUM FULL')
```

Thanks.
