def load_sql_csv(connection, input_dir):
    """
    Load the CSV files we created into PostgreSQL using the `copy_from`
    method, which is the same as the COPY command at the psql command line.
    """
    for filename, tablename in [(input_dir + '/relations.csv', 'relations'),
        (input_dir + '/nodes.csv', 'nodes'), (input_dir + '/edges.csv',
        'edges'), (input_dir + '/sources.csv', 'sources'), (input_dir +
        '/edges_gin.shuf.csv', 'edges_gin'), (input_dir +
        '/edge_features.csv', 'edge_features')]:
        with connection.cursor() as cursor:
            with open(filename, 'rb') as file:
                cursor.copy_from(file, tablename)
        connection.commit()
