From 2ad5e43a3005736b012cbb018116c78fba607185 Mon Sep 17 00:00:00 2001 From: jason Date: Sat, 11 Aug 2012 11:10:36 -0600 Subject: create a settings db and tables. --- settings.py | 2 ++ warmachine | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/settings.py b/settings.py index f0c930e..bdb1e17 100644 --- a/settings.py +++ b/settings.py @@ -15,6 +15,8 @@ CHANNELS = ('#warmachine-dev',) ADMINS = ('com4',) +DB_PATH = "warmachine.db" + ACTIONS = ( 'wmd.actions.passive.nickserv.IdentWithNickserv', 'wmd.actions.passive.pong.RespondToPing', diff --git a/warmachine b/warmachine index d44f0c1..e4a461a 100755 --- a/warmachine +++ b/warmachine @@ -1,8 +1,33 @@ #!/usr/bin/env python +import sqlite3 + from wmd.irc import IRC import settings if __name__ == '__main__': + connection = sqlite3.connect(settings.DB_PATH) + c = connection.cursor() + + # check to see if a table exists + is_installed = bool(c.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='warmachine_settings'").fetchone()) + print is_installed + if not is_installed: + c.execute("""CREATE TABLE warmachine_settings ( + key text, + value text, + plugin text, + primary key (key, plugin) + ); + """) + c.execute("""CREATE TABLE warmachine_plugins ( + id text, + name text, + description text, + is_active int, + primary key (id) + ); + """) + i = IRC(settings.SERVER, settings.NICKNAME, settings.IDENT, settings.PORT) i.connect() for channel in settings.CHANNELS: -- cgit v1.2.1