예제 #1
0
def init(request):

    query1 = query_create_table1("ex08_planets")
    query2 = query_create_table2("ex08_people")

    res1 = result_query_execute(query1)
    res2 = result_query_execute(query2)

    return render(request, "ex08.html", {'res1': res1, 'res2': res2})
예제 #2
0
def add_item(movie_id, text, table):

    query = """UPDATE {} SET opening_crawl = '{}' WHERE episode_nb={}""".format(
        table, text, movie_id)
    res_up = result_query_execute(query)

    return res_up
예제 #3
0
def init(request):

    query = query_create_table("ex06_movies")

    res = result_query_execute(query)

    return HttpResponse(res)
예제 #4
0
def delete_item(movie_id, table):

    query = """DELETE FROM {} WHERE episode_nb={}""".format(table, movie_id)

    res_del = result_query_execute(query)

    return res_del
예제 #5
0
def define_query(table):

    query_post_list = [
        (1, 'The Phantom Menace', 'George Lucas', 'Rick McCallum', '1999-05-19'),
        (2, 'Attack of the Clones', 'George Lucas', 'Rick McCallum', '2002-05-16'),
        (3, 'Revenge of the Sith', 'George Lucas', 'Rick McCallum', '2005-05-19'),
        (4, 'A New Hope', 'George Lucas', 'Gary Kurtz, Rick McCallum', '1977-05-25'),
        (5, 'The Empire Strikes Back', 'Irvin Kershner', 'Gary Kutz, Rick McCallum', '1980-05-17'),
        (6, 'Return of the Jedi', 'Richard Marquand', 'Howard G. Kazanjian, Georges Lucas, Rick McCallum', '1983-05-25'),
        (7, 'The Force Awakens', 'J. J Abrams', 'Kathleen Kennedy, J. J. Abrams, Bryan Burk', '2015-12-11')
    ]

    string_results = ''

    for query in query_post_list:

        query_str = """
        INSERT INTO {0}(episode_nb, title, director, producer, release_date) VALUES {1}
        """.format(table, query)


        res = str(result_query_execute(query_str))

        if res == "OK":
            string_results += "OK  -----  {}<br>".format(query[1])
        else:
            string_results += "FAIL ----  {0:} : &nbsp;&nbsp;&nbsp;{1}<br>".format(query[1], res)

    return string_results