Create Loading job using python code

does anyone has python code to run or create loading job on GSQL.

1 Like

Hi atulparihar,

This notebook contains examples of all pyTigerGraph functions including loading job creations and running.

You can create a Loading Job using pytigerGraph’s .gsql() function and the standard loading job procedure defined here like below:

conn.gsql('''
USE GRAPH MDC
BEGIN
CREATE LOADING JOB load_site_visits FOR GRAPH MDC {
    DEFINE FILENAME MyDataSource;
    LOAD MyDataSource TO VERTEX Date VALUES($1) USING SEPARATOR=",", HEADER="true", EOL="\\n", QUOTE="double";
    LOAD MyDataSource TO VERTEX Site VALUES($0) USING SEPARATOR=",", HEADER="true", EOL="\\n", QUOTE="double";
    LOAD MyDataSource TO EDGE VISITED_ON VALUES($0, $1, $2, $3) USING SEPARATOR=",", HEADER="true", EOL="\\n", QUOTE="double";
}
''')

You can run the Loading Job using a local file to your python environment like this:

video_file = './YT_Video_Views/Chart data.csv'
conn.uploadFile(video_file, fileTag="MyDataSource", jobName="load_youtube_videos")

Or from a file on your TigerGraph server like this:

dataSource = "/home/tigergraph/tigergraph/data/gui/loading_data/movies.csv"
results = conn.gsql('''
USE GRAPH MyGraph
RUN LOADING JOB load_job_movies_csv_1535566300087 USING MyDataSource="'+dataSource+'"
''')
1 Like

Thanks for the response, i’ll definately use