def insert_spo_tuple(self, spo_tuple):
    '\n        \n        Handles the insertion of spo tuples into the db. Workflow:\n        \n        Attempt to find the subject table entry corresponding to your subject. If found, use that ID for\n        inserting your po values. Otherwise, insert your subject into the subject table and use that ID\n        instead. The resulting id, predicate, object tuple is then inserted into the predicate_object table.\n        \n        :param spo_tuple: \n        :return: \n        '
    (subject, predicate, db_object) = spo_tuple
    with self.connection.cursor(cursor_factory=psycopg2.extras.RealDictCursor) as cursor:
        cursor.execute('select subject_id from dbpedia.subjects where name = %s', (subject,))
        results = cursor.fetchone()
        if ((results is None) or (len(results) == 0)):
            cursor.execute('INSERT INTO dbpedia.subjects (name) VALUES (%s) returning subject_id', (subject,))
            results = cursor.fetchone()
        id = results['subject_id']
        cursor.execute('INSERT INTO dbpedia.predicate_object (subject_id, predicate, object) VALUES (%s, %s, %s)', (id, predicate, db_object))
Handles the insertion of spo tuples into the db. Workflow:

Attempt to find the subject table entry corresponding to your subject. If found, use that ID for
inserting your po values. Otherwise, insert your subject into the subject table and use that ID
instead. The resulting id, predicate, object tuple is then inserted into the predicate_object table.

:param spo_tuple: 
:return:
def insert_spo_tuple(self, spo_tuple):
    '\n        \n        Handles the insertion of spo tuples into the db. Workflow:\n        \n        Attempt to find the subject table entry corresponding to your subject. If found, use that ID for\n        inserting your po values. Otherwise, insert your subject into the subject table and use that ID\n        instead. The resulting id, predicate, object tuple is then inserted into the predicate_object table.\n        \n        :param spo_tuple: \n        :return: \n        '
    (subject, predicate, db_object) = spo_tuple
    with self.connection.cursor(cursor_factory=psycopg2.extras.RealDictCursor) as cursor:
        cursor.execute('select subject_id from dbpedia.subjects where name = %s', (subject,))
        results = cursor.fetchone()
        if ((results is None) or (len(results) == 0)):
            cursor.execute('INSERT INTO dbpedia.subjects (name) VALUES (%s) returning subject_id', (subject,))
            results = cursor.fetchone()
        id = results['subject_id']
        cursor.execute('INSERT INTO dbpedia.predicate_object (subject_id, predicate, object) VALUES (%s, %s, %s)', (id, predicate, db_object))