nxy/bot/plugins/storage.py
2017-07-07 02:49:37 +02:00

19 lines
473 B
Python

# -*- coding: utf-8 -*-
import os
import irc3
import psycopg2
from psycopg2.extras import DictCursor
from . import Plugin
@irc3.plugin
class Storage(Plugin):
def __init__(self, bot: irc3.IrcBot):
super().__init__(bot)
# Create database connection
self.con = psycopg2.connect(os.environ['DATABASE_URI'])
# Create database cursor (with dict factory to access rows by name)
self.cur = self.con.cursor(cursor_factory=DictCursor)