nxy/bot/plugins/storage.py

19 lines
473 B
Python
Raw Normal View History

# -*- 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'])
2017-07-04 13:22:20 +00:00
# Create database cursor (with dict factory to access rows by name)
self.cur = self.con.cursor(cursor_factory=DictCursor)