I have a query (sql1) that populates data, and I am trying to insert the outcome of this data (sql1) as well as other inputs into same table.
Here is first query (sql1).
sql1 = ' Select Creator_Id, Record_Id, max(Course_Num) + 1, SiteCode ' \
' from ' \
' (Select Creator_Id, Record_Id, max(Course_Num) + 1, SiteCode from Courses ' \
' where ( Record_Id not in ("Test") ) ' \
' group by Record_Id '
cursor.execute(sql1)
all = cursor.fetchall()
I am not sure bottom code is correct (where fields %s comes in and rest fields).
for Creator_Id, Record_Id, Course_Num, SiteCode in all:
sql2 = ' Insert into Courses ' \
' ( Creator_Id, ' \
' Record_Id, ' \
' Course_Num, ' \
' SiteCode, ' \
' coursename, ' \
' datestamp ) ' \
' VALUES ' \
' ( %s, %s, %s, %s, %s, %s ) ' \
How do I express/complete something like on the bottom on this case (where I have two more columns to insert)?
I got this sample from other post, but not I am sure how to apply Key(s) of the value.
Sorry, I need some guidance regards to what I am doing here.
cursor.execute(sql2, (Cretor_Id, Record_Id, Course_Num, SiteCode), "UniqueCourseName", "")