def get_users(self):
        """
        Get list of users.
        """

        keys_on = "PRAGMA foreign_keys = ON"
        query = "SELECT * FROM users"

        # user_nickname = None

        # connects (and creates if necessary) to the database. gets a connection object
        # con = sqlite3.connect(self.database_name)
        con = sqlite3.connect(self.database_name)
        with con:
            con.row_factory = sqlite3.Row
            cur = con.cursor()
            cur.execute(keys_on)
            # execute the statement
            cur.execute(query)
            # get results
            rows = cur.fetchall()
            if len(rows) == 0:
                return None

            users = []
            for row in rows:
                users.append(UserModel.create(row))
            return users
    def get_users(self):
        '''
        Get list of users.
        '''

        keys_on = 'PRAGMA foreign_keys = ON'
        query = 'SELECT * FROM users'

        #user_nickname = None

        #connects (and creates if necessary) to the database. gets a connection object
        #con = sqlite3.connect(self.database_name)
        con = sqlite3.connect(self.database_name)
        with con:
            con.row_factory = sqlite3.Row
            cur = con.cursor()
            cur.execute(keys_on)
            #execute the statement
            cur.execute(query)
            #get results
            rows = cur.fetchall()
            if len(rows) == 0:
                return None

            users = []
            for row in rows:
                users.append(UserModel.create(row))
            return users
    def get_user(self, user_nickname):
        """
        returns user.
        Return "None" if user not found.
        """

        keys_on = "PRAGMA foreign_keys = ON"
        query = "SELECT * FROM users WHERE user_nickname = ?"
        pvalue = (user_nickname,)

        # user_nickname = None

        # connects (and creates if necessary) to the database. gets a connection object
        # con = sqlite3.connect(self.database_name)
        con = sqlite3.connect(self.database_name)
        with con:
            con.row_factory = sqlite3.Row
            cur = con.cursor()
            cur.execute(keys_on)
            # execute the statement
            cur.execute(query, pvalue)
            # just one result possible
            row = cur.fetchone()
            if row is None:
                return None
            else:
                # print row.keys()

                return UserModel.create(row)
    def get_user(self, user_nickname):
        '''
        returns user.
        Return "None" if user not found.
        '''

        keys_on = 'PRAGMA foreign_keys = ON'
        query = 'SELECT * FROM users WHERE user_nickname = ?'
        pvalue = (user_nickname, )

        #user_nickname = None

        #connects (and creates if necessary) to the database. gets a connection object
        #con = sqlite3.connect(self.database_name)
        con = sqlite3.connect(self.database_name)
        with con:
            con.row_factory = sqlite3.Row
            cur = con.cursor()
            cur.execute(keys_on)
            #execute the statement
            cur.execute(query, pvalue)
            #just one result possible
            row = cur.fetchone()
            if row is None:
                return None
            else:
                #print row.keys()

                return UserModel.create(row)