Skip to content

Commit 8c638d0

Browse files
authored
Merge pull request pytest-dev#61 from mrbox/master
Make db_url work with async databases
2 parents fd72c51 + 4b3880f commit 8c638d0

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

peewee_async.py

+14
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import warnings
2222
import logging
2323

24+
from playhouse.db_url import register_database
25+
2426
logger = logging.getLogger('peewee.async')
2527
logger.addHandler(logging.NullHandler())
2628

@@ -1172,6 +1174,9 @@ def use_speedups(self, value):
11721174
pass
11731175

11741176

1177+
register_database(PostgresqlDatabase, 'postgres+async', 'postgresql+async')
1178+
1179+
11751180
class PooledPostgresqlDatabase(AsyncPostgresqlMixin, peewee.PostgresqlDatabase):
11761181
"""PosgreSQL database driver providing **single drop-in sync**
11771182
connection and **async connections pool** interface.
@@ -1200,6 +1205,9 @@ def use_speedups(self, value):
12001205
pass
12011206

12021207

1208+
register_database(PooledPostgresqlDatabase, 'postgres+pool+async', 'postgresql+pool+async')
1209+
1210+
12031211
#########
12041212
# MySQL #
12051213
#########
@@ -1318,6 +1326,9 @@ def use_speedups(self, value):
13181326
pass
13191327

13201328

1329+
register_database(MySQLDatabase, 'mysql+async')
1330+
1331+
13211332
class PooledMySQLDatabase(MySQLDatabase):
13221333
"""MySQL database driver providing **single drop-in sync**
13231334
connection and **async connections pool** interface.
@@ -1339,6 +1350,9 @@ def init(self, database, **kwargs):
13391350
self.max_connections = max_connections
13401351

13411352

1353+
register_database(PooledMySQLDatabase, 'mysql+pool+async')
1354+
1355+
13421356
##############
13431357
# Sync utils #
13441358
##############

peewee_asyncext.py

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
Copyright (c) 2014, Alexey Kinëv <[email protected]>
1414
1515
"""
16+
from playhouse.db_url import register_database
17+
1618
from peewee_async import AsyncPostgresqlMixin
1719
import playhouse.postgres_ext as ext
1820

@@ -47,6 +49,9 @@ def use_speedups(self, value):
4749
pass
4850

4951

52+
register_database(PostgresqlExtDatabase, 'postgresext+async', 'postgresqlext+async')
53+
54+
5055
class PooledPostgresqlExtDatabase(AsyncPostgresqlMixin, ext.PostgresqlExtDatabase):
5156
"""PosgreSQL database extended driver providing **single drop-in sync**
5257
connection and **async connections pool** interface.
@@ -78,3 +83,6 @@ def use_speedups(self):
7883
@use_speedups.setter
7984
def use_speedups(self, value):
8085
pass
86+
87+
88+
register_database(PooledPostgresqlExtDatabase, 'postgresext+pool+async', 'postgresqlext+pool+async')

0 commit comments

Comments
 (0)