from pysqlite2 import dbapi2 as sqlite import os, sys mypath = os.path.dirname(os.path.abspath(__file__)) databasedir = os.path.join(mypath, 'a.db') class DataBase(object): databasedir = os.path.join( os.path.abspath(sys.argv[0]), 'brain.db') def connect(self): self.con = sqlite.connect(databasedir) self.cur = con.cursor() def show_commands(self): self.connect() self.cur.execute('SELECT command FROM knowledge') a = '' for output in self.cur.fetchall(): a += output + ' | ' return a def write_to(self, command, text): self.connect() self.cur.execute('INSERT INTO knowledge (command, text) VALUES (?, ?)', (command, text)) self.con.commit() print ' *************************************\n' print mypath, ' ', databasedir print ' *************************************\n' @@print DataBase.show_commands() print ' *************************************\n' Traceback (most recent call last): File "a.py", line 32, in ? print DataBase.show_commands() TypeError: unbound method show_commands() must be called with DataBase instance as first argument (got nothing instead)