modify db connection
This commit is contained in:
parent
e791887485
commit
f725080478
7
bot.py
7
bot.py
@ -32,6 +32,7 @@ from discord.ext import commands
|
|||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
import asyncio
|
||||||
import asyncpg
|
import asyncpg
|
||||||
from concurrent import futures
|
from concurrent import futures
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
@ -73,7 +74,7 @@ class Submitter(commands.Bot):
|
|||||||
self.infected = {}
|
self.infected = {}
|
||||||
self.TOKEN = self.bot_secrets['token']
|
self.TOKEN = self.bot_secrets['token']
|
||||||
del self.bot_secrets['token']
|
del self.bot_secrets['token']
|
||||||
self.db_con = None
|
self.db_con = asyncio.get_event_loop().run_until_complete(self.connect_db())
|
||||||
self.default_prefix = '!'
|
self.default_prefix = '!'
|
||||||
self.tpe = futures.ThreadPoolExecutor()
|
self.tpe = futures.ThreadPoolExecutor()
|
||||||
self.embed_color = discord.Colour.from_rgb(49, 107, 111)
|
self.embed_color = discord.Colour.from_rgb(49, 107, 111)
|
||||||
@ -86,8 +87,8 @@ class Submitter(commands.Bot):
|
|||||||
'o': '🇴',
|
'o': '🇴',
|
||||||
}
|
}
|
||||||
|
|
||||||
async def connect_db(self):
|
async def connect_db():
|
||||||
self.db_con = await asyncpg.create_pool(host=self.bot_secrets['db_con']['host'],
|
return await asyncpg.create_pool(host=self.bot_secrets['db_con']['host'],
|
||||||
database=self.bot_secrets['db_con']['db_name'],
|
database=self.bot_secrets['db_con']['db_name'],
|
||||||
user=self.bot_secrets['db_con']['user'],
|
user=self.bot_secrets['db_con']['user'],
|
||||||
password=self.bot_secrets['db_con']['password'],
|
password=self.bot_secrets['db_con']['password'],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user