This question is a spin off a previous question here in which a database was created. However, when it comes to add information to that dataset I can go manually adding information or going via a programmatically way. The latter is my choice for a didactic reason.
The equivalent of what I am trying to do in python is:
for x in cursor.execute(sql):
lastid = x[0]
# Insert data into the instructions table
sql = 'INSERT INTO Instructions (recipeID,instructions) VALUES( %s,"Brown hamburger. Stir in all other ingredients. Bring to a boil. Stir. Lower to simmer. Cover and cook for 20 minutes or until all liquid is absorbed.")' % lastid
cursor.execute(sql)
The way I am going about it is:
//Insert the rest of instructions
var last_id = db.last_insert_rowid()
for var x in last_id
query = """INSERT INTO Instructions (recipeID,instructions) VALUES(
%s,
"Brown hamburger. Stir in all other ingredients. Bring to a boil. Stir. Lower to simmer. Cover and cook for 20 minutes or until all liquid is absorbed."
), x
"""
However, it seems that last_id is a int64 type that cannot be an iterator, as per the error that I get:
valac --pkg sqlite3 cookcreate.gs cookcreate.gs:55.18-55.24: error:
int64' does not have an
iterator' method for var x in last_id ^^^^^^^ Compilation failed: 1 error(s), 0 warning(s)
How to solve this problem with code in Genie? Should I convert it to another type, that accepts being used as an iterator? Also, is that syntax (%s), x
correct?
Thanks