From 55e87b3fc3da14a6edfd50003bd8babccf6e5fe9 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Sun, 2 Aug 2020 00:23:19 +0100 Subject: [PATCH] DB Connection is now created within the same event loop as client Referencing pool connection from client/self.bot --- cogs/relationship.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/cogs/relationship.py b/cogs/relationship.py index 935c262e..c2a2ed25 100644 --- a/cogs/relationship.py +++ b/cogs/relationship.py @@ -5,8 +5,6 @@ import random from discord import Member, Embed, Colour from discord.ext.commands import BucketType, command, cooldown, bot_has_permissions, Cog -import db -from db import connection from settings import colour_list @@ -62,7 +60,7 @@ class Relationship(Cog): # Getting the guild of the user guild = ctx.author.guild # Setup pool - pool = await connection(db.loop) + pool = self.bot.db # Setup pool connection and cursor async with pool.acquire() as conn: @@ -118,7 +116,7 @@ class Relationship(Cog): if msg.content.lower() in ['y', 'yes', 'yea']: # Setup pool - pool = await connection(db.loop) + pool = self.bot.db # Setup pool connection and cursor async with pool.acquire() as conn: @@ -162,7 +160,7 @@ class Relationship(Cog): # Getting the guild of the user guild = ctx.author.guild # Setup pool - pool = await connection(db.loop) + pool = self.bot.db # Setup pool connection and cursor async with pool.acquire() as conn: @@ -210,7 +208,7 @@ class Relationship(Cog): # if the person says yes if msg.content.lower() in ['y', 'yes', 'yea']: # Setup pool - pool = await connection(db.loop) + pool = self.bot.db # Setup pool connection and cursor async with pool.acquire() as conn: @@ -265,7 +263,7 @@ class Relationship(Cog): guild = member.guild # Setup pool - pool = await connection(db.loop) + pool = self.bot.db # Setup pool connection and cursor async with pool.acquire() as conn: