'Naively inserts key-value pairs into a table, given a dictionary.'

def insert_dict(self, session, table_name, d, table=None):

    if (table is None):
        this_table = sqlalchemy.Table(table_name, self.metadata, autoload=True)
    else:
        this_table = table
    insert = this_table.insert().values(**d)
    session.execute(insert)
