aboutsummaryrefslogtreecommitdiff
path: root/src/Database.py
diff options
context:
space:
mode:
authorGravatar jesopo2018-09-27 11:07:29 +0100
committerGravatar jesopo2018-09-27 11:07:29 +0100
commitaf2b34b92b30aa5a51d385e6137f0716dd7a7935 (patch)
treea96f5ab92678ebad022b53fd5fac0b068db1f009 /src/Database.py
parentFix event typo in greeting.py ("recevied" -> "received") (diff)
signature
Don't give IRCBot instance to things that don't need it, use a better way of
doing default locations for config/database/log
Diffstat (limited to 'src/Database.py')
-rw-r--r--src/Database.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/Database.py b/src/Database.py
index 3bf3fe90..6abf0362 100644
--- a/src/Database.py
+++ b/src/Database.py
@@ -239,11 +239,10 @@ class UserChannelSettings(Table):
[user_id, channel_id, setting.lower()])
class Database(object):
- def __init__(self, bot, directory, filename):
- self.bot = bot
- self.filename = filename
- self.full_location = os.path.join(directory, filename)
- self.database = sqlite3.connect(self.full_location,
+ def __init__(self, log, location):
+ self.log = log
+ self.location = location
+ self.database = sqlite3.connect(self.location,
check_same_thread=False, isolation_level=None)
self.database.execute("PRAGMA foreign_keys = ON")
self._cursor = None
@@ -273,7 +272,7 @@ class Database(object):
def _execute_fetch(self, query, fetch_func, params=[]):
printable_query = " ".join(query.split())
- self.bot.log.debug("executing query: \"%s\" (params: %s)",
+ self.log.debug("executing query: \"%s\" (params: %s)",
[printable_query, params])
start = time.monotonic()
@@ -283,7 +282,7 @@ class Database(object):
end = time.monotonic()
total_milliseconds = (end - start) * 1000
- self.bot.log.debug("executed in %fms", [total_milliseconds])
+ self.log.debug("executed in %fms", [total_milliseconds])
return value
def execute_fetchall(self, query, params=[]):