Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

Commit 683563e

Browse files
Version 0.1.7
1 parent bcbc46b commit 683563e

File tree

4 files changed

+18
-28
lines changed

4 files changed

+18
-28
lines changed

databases/backends/mysql.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ def _get_connection_kwargs(self) -> dict:
2626
options = self._database_url.options
2727

2828
kwargs = {}
29-
min_size = options.get('min_size')
30-
max_size = options.get('max_size')
31-
ssl = options.get('ssl')
29+
min_size = options.get("min_size")
30+
max_size = options.get("max_size")
31+
ssl = options.get("ssl")
3232

3333
if min_size is not None:
34-
kwargs['minsize'] = int(min_size)
34+
kwargs["minsize"] = int(min_size)
3535
if max_size is not None:
36-
kwargs['maxsize'] = int(max_size)
36+
kwargs["maxsize"] = int(max_size)
3737
if ssl is not None:
38-
kwargs['ssl'] = {'true': True, 'false': False}[ssl.lower()]
38+
kwargs["ssl"] = {"true": True, "false": False}[ssl.lower()]
3939
return kwargs
4040

4141
async def connect(self) -> None:
@@ -48,7 +48,7 @@ async def connect(self) -> None:
4848
password=self._database_url.password,
4949
db=self._database_url.database,
5050
autocommit=True,
51-
**kwargs
51+
**kwargs,
5252
)
5353

5454
async def disconnect(self) -> None:

databases/backends/postgres.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ def _get_connection_kwargs(self) -> dict:
3737
options = self._database_url.options
3838

3939
kwargs = {}
40-
min_size = options.get('min_size')
41-
max_size = options.get('max_size')
42-
ssl = options.get('ssl')
40+
min_size = options.get("min_size")
41+
max_size = options.get("max_size")
42+
ssl = options.get("ssl")
4343

4444
if min_size is not None:
45-
kwargs['min_size'] = int(min_size)
45+
kwargs["min_size"] = int(min_size)
4646
if max_size is not None:
47-
kwargs['max_size'] = int(max_size)
47+
kwargs["max_size"] = int(max_size)
4848
if ssl is not None:
49-
kwargs['ssl'] = {'true': True, 'false': False}[ssl.lower()]
49+
kwargs["ssl"] = {"true": True, "false": False}[ssl.lower()]
5050
return kwargs
5151

5252
async def connect(self) -> None:

databases/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44
import typing
55
from types import TracebackType
6-
from urllib.parse import SplitResult, urlsplit, parse_qsl
6+
from urllib.parse import SplitResult, parse_qsl, urlsplit
77

88
from sqlalchemy.engine import RowProxy
99
from sqlalchemy.sql import ClauseElement

tests/test_connection_options.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,22 @@
99
def test_postgres_pool_size():
1010
backend = PostgresBackend("postgres://localhost/database?min_size=1&max_size=20")
1111
kwargs = backend._get_connection_kwargs()
12-
assert kwargs == {
13-
'min_size': 1,
14-
'max_size': 20
15-
}
12+
assert kwargs == {"min_size": 1, "max_size": 20}
1613

1714

1815
def test_postgres_ssl():
1916
backend = PostgresBackend("postgres://localhost/database?ssl=true")
2017
kwargs = backend._get_connection_kwargs()
21-
assert kwargs == {
22-
'ssl': True,
23-
}
18+
assert kwargs == {"ssl": True}
2419

2520

2621
def test_mysql_pool_size():
2722
backend = MySQLBackend("mysql://localhost/database?min_size=1&max_size=20")
2823
kwargs = backend._get_connection_kwargs()
29-
assert kwargs == {
30-
'minsize': 1,
31-
'maxsize': 20
32-
}
24+
assert kwargs == {"minsize": 1, "maxsize": 20}
3325

3426

3527
def test_mysql_ssl():
3628
backend = MySQLBackend("postgres://localhost/database?ssl=true")
3729
kwargs = backend._get_connection_kwargs()
38-
assert kwargs == {
39-
'ssl': True,
40-
}
30+
assert kwargs == {"ssl": True}

0 commit comments

Comments
 (0)