1
1
import asyncpg
2
2
import logging
3
+ import ssl
4
+
3
5
4
6
def conn (func ):
5
- """
6
- Add every connection to a connection pool
7
- """
8
- async def decor (self , * args , ** kwargs ):
9
- async with self .pool .acquire () as conn :
10
- # TODO: make working transaction wrapper (? in separate func)
11
- # try `return await func(self, conn, *args, **kwargs)` to be able to use *args
12
- return await func (self , conn = conn , * args , ** kwargs )
13
- return decor
7
+ """
8
+ Add every connection to a connection pool
9
+ """
10
+ async def decor (self , * args , ** kwargs ):
11
+ async with self .pool .acquire () as conn :
12
+ # TODO: make working transaction wrapper (? in separate func)
13
+ # try `return await func(self, conn, *args, **kwargs)` to be able to use *args
14
+ return await func (self , conn = conn , * args , ** kwargs )
15
+ return decor
16
+
14
17
15
18
class DataBase ():
16
19
@classmethod
@@ -20,7 +23,10 @@ async def connect(cls, DATABASE_URL):
20
23
also create db if not exists
21
24
"""
22
25
self = DataBase ()
23
- self .pool = await asyncpg .create_pool (DATABASE_URL )
26
+ ctx = ssl .create_default_context (cafile = 'concatenated.pem' )
27
+ ctx .check_hostname = False
28
+ ctx .verify_mode = ssl .CERT_NONE
29
+ self .pool = await asyncpg .create_pool (DATABASE_URL , ssl = ctx )
24
30
await self .create_db ()
25
31
return self
26
32
0 commit comments