From e5ff94e9d0a2ed6a2bf048fe37e9d18308ad5f77 Mon Sep 17 00:00:00 2001 From: CMDR furrycat Date: Mon, 3 Oct 2016 22:09:42 +0100 Subject: [PATCH] DB tidyup. --- db.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/db.py b/db.py index b07c62f..7796a0d 100644 --- a/db.py +++ b/db.py @@ -1,6 +1,7 @@ import discord import logging import sqlite3 +import time import uuid log = logging.getLogger('db') @@ -12,9 +13,12 @@ class DBConnection(object): self.open_db(filename) self.create_tables() - def uuid(): + def uuid(self): return str(uuid.uuid4()) + def now(self): + return int(time.time()) + def open_db(self, filename): self.dbh = sqlite3.connect(filename) self.dbh.row_factory = sqlite3.Row @@ -33,8 +37,7 @@ class DBConnection(object): return cursor def get_state(self, client): - cursor = self.dbh.cursor() - self.query('select avatar, idle, last_spoke from state where bot_id=?', [client.user.id]) + cursor = self.query('select avatar, idle, last_spoke from state where bot_id=?', [client.user.id]) row = cursor.fetchone() if row is None: return None -- 2.7.4