diff options
| author | 2018-09-27 11:07:29 +0100 | |
|---|---|---|
| committer | 2018-09-27 11:07:29 +0100 | |
| commit | af2b34b92b30aa5a51d385e6137f0716dd7a7935 (patch) | |
| tree | a96f5ab92678ebad022b53fd5fac0b068db1f009 /src/Database.py | |
| parent | Fix 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.py | 13 |
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=[]): |
