Postgres transaction isolation level 
The underlying psycopg2 connection class is exposed as `db.connection()`, e.g.

```python
db = PostgresqlDatabase('my_app')
conn = db.connection()  # returns current conn, opening one if necessary
```

Then use the psycopg2 apis to set the isolation level:

```python
from psycopg2 import extensions
conn.set_isolation_level(extensions.ISOLATION_LEVEL_REPEATABLE_READ)
```

You can put all this in a hook provided by peewee and executed automatically when a new connection is created.

```python

class RCPostgresqlDatabase(PostgresqlDatabase):
    def _initialize_connection(self, conn):
        conn.set_isolation_level(...)
```

This hook is called whenever a new connection is opened, so its probably what you're looking for. Added support for passing this into the PostgresqlDatabase `__init__()` method in master, will be available in the next release. @coleifer Thanks for the quick response and the code addition!

Do you have any plan to add isolation level as a parameter to `db.atomic()` or `db.transaction()` in the future? Sometimes per-transaction config is needed rather than per-session....
 Not really, it seems from the psycopg2 docs that when you set the isolation level it is for the duration of the session, so there doesn't seem to be an API that is just for the lifetime of a transaction. Because of this, I'm inclined to leave it as an exercise to the reader to implement a context-manager or whatever you need. ```python
@contextmanager
def isolation(level):
    conn = db.connection()
    orig = conn.isolation_level
    conn.set_isolation_level(level)
    try:
        with db.atomic() as txn:
            yield txn
    finally:
        conn.set_isolation_level(orig)
```

Something like this? OK. Thanks again.

In case someone else will encounter this thread - another possible option (which i didn't try) is to use raw [`SET TRANSACTION`](https://www.postgresql.org/docs/9.5/sql-set-transaction.html) statement which should be ran before any other query in the transaction.
Hi,
Probably I'm missing something but I couldn't find a way to specify transaction isolation level for Postgres (default to [`Read committed`](https://www.postgresql.org/docs/9.5/transaction-iso.html) which is not sufficient for my use case - in which `Repeatable read` is needed).

Any way to workaround it (without changing postgres config or manually open transaction)?

Thanks a lot!