Switch to Asyncpg for db con
This commit is contained in:
parent
8c702a854d
commit
996d7a3ea3
@ -3,10 +3,10 @@ import asyncio
|
|||||||
|
|
||||||
|
|
||||||
class DatabaseConnection:
|
class DatabaseConnection:
|
||||||
def __init__(self, host: str='localhost', port: int=5432, database: str='', username: str='', password: str=''):
|
def __init__(self, host: str='localhost', port: int=5432, database: str='', user: str='', password: str=''):
|
||||||
if username == '' or password == '' or database == '':
|
if user == '' or password == '' or database == '':
|
||||||
raise RuntimeError('Username or Password are blank')
|
raise RuntimeError('Username or Password are blank')
|
||||||
self.kwargs = {'host': host, 'port': port, 'database': database, 'username': username, 'password': password}
|
self.kwargs = {'host': host, 'port': port, 'database': database, 'user': user, 'password': password}
|
||||||
self._conn = None
|
self._conn = None
|
||||||
asyncio.get_event_loop().run_until_complete(self.acquire())
|
asyncio.get_event_loop().run_until_complete(self.acquire())
|
||||||
self.fetchval = self._conn.fetchval
|
self.fetchval = self._conn.fetchval
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user