Search code examples
pythonjsonconnection-poolingpeeweepostgresql-9.4

Peewee Connection pooling with postgresql 9.4 and JSON fields support


Knowing that there is already support for connection pooling for Postgres in Peewee, and also support for JSON fields in Postgres, I would like to know if PooledPostgresqlDatabase actually supports those JSON fields too, and if not how can i do to get that working as a PostgresqlExtDatabase.


Solution

  • There is an class named PooledPostgresqlExtDatabase which supports both pooling in the way PostgresqlExtDatabase does but with connection pooling support:

    from playhouse.pool import PooledPostgresqlExtDatabase
    
    db = PooledPostgresqlExtDatabase(
        'my_database',
        max_connections=8,
        stale_timeout=300,
        user='postgres')