この質問は、データベースが作成された以前の質問hereから派生したものです。ただし、そのデータセットに情報を追加する場合は、手動で情報を追加するか、プログラムを使用して情報を追加できます。後者は、教訓的な理由で私の選択です。
私がPythonでやろうとしていることと同等のものは次のとおりです。
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)
私が行っている方法は次のとおりです。
//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
"""
しかし、私が得るエラーによると、 last_id はイテレータになれない int64 型のようです:
valac --pkg sqlite3 cookcreate.gs cookcreate.gs:55.18-55.24: エラー: last_id
int64' does not have an
の var x の反復子メソッド ^^^^^^^ コンパイルに失敗しました: 1 エラー、0 警告
Genie のコードでこの問題を解決するにはどうすればよいですか? イテレータとしての使用を受け入れる別の型に変換する必要がありますか? また、その構文は(%s), x
正しいですか?
ありがとう