Skip to content

Commit

Permalink
Merge pull request #61 from mrbox/master
Browse files Browse the repository at this point in the history
Make db_url work with async databases
  • Loading branch information
rudyryk committed Oct 22, 2017
2 parents fd72c51 + 4b3880f commit 8c638d0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions peewee_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import warnings
import logging

from playhouse.db_url import register_database

logger = logging.getLogger('peewee.async')
logger.addHandler(logging.NullHandler())

Expand Down Expand Up @@ -1172,6 +1174,9 @@ def use_speedups(self, value):
pass


register_database(PostgresqlDatabase, 'postgres+async', 'postgresql+async')


class PooledPostgresqlDatabase(AsyncPostgresqlMixin, peewee.PostgresqlDatabase):
"""PosgreSQL database driver providing **single drop-in sync**
connection and **async connections pool** interface.
Expand Down Expand Up @@ -1200,6 +1205,9 @@ def use_speedups(self, value):
pass


register_database(PooledPostgresqlDatabase, 'postgres+pool+async', 'postgresql+pool+async')


#########
# MySQL #
#########
Expand Down Expand Up @@ -1318,6 +1326,9 @@ def use_speedups(self, value):
pass


register_database(MySQLDatabase, 'mysql+async')


class PooledMySQLDatabase(MySQLDatabase):
"""MySQL database driver providing **single drop-in sync**
connection and **async connections pool** interface.
Expand All @@ -1339,6 +1350,9 @@ def init(self, database, **kwargs):
self.max_connections = max_connections


register_database(PooledMySQLDatabase, 'mysql+pool+async')


##############
# Sync utils #
##############
Expand Down
8 changes: 8 additions & 0 deletions peewee_asyncext.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
Copyright (c) 2014, Alexey Kinëv <rudy@05bit.com>
"""
from playhouse.db_url import register_database

from peewee_async import AsyncPostgresqlMixin
import playhouse.postgres_ext as ext

Expand Down Expand Up @@ -47,6 +49,9 @@ def use_speedups(self, value):
pass


register_database(PostgresqlExtDatabase, 'postgresext+async', 'postgresqlext+async')


class PooledPostgresqlExtDatabase(AsyncPostgresqlMixin, ext.PostgresqlExtDatabase):
"""PosgreSQL database extended driver providing **single drop-in sync**
connection and **async connections pool** interface.
Expand Down Expand Up @@ -78,3 +83,6 @@ def use_speedups(self):
@use_speedups.setter
def use_speedups(self, value):
pass


register_database(PooledPostgresqlExtDatabase, 'postgresext+pool+async', 'postgresqlext+pool+async')

0 comments on commit 8c638d0

Please sign in to comment.