Nun stellt sich mir die Frage, ob ich mittels Mehrfachauswahl (html <select .... multiple>) die Autoren mit einem "klick" zuweisen kann.
Dafür müsste ich aber eine Art Schleife einbauen, welche die Anzahl ausgewählter Autoren ausliest und dann diese mit der buchID in mehrere Zeilen einfügt?
Gibt es da eine Möglichkeit bzw hätte jemand eine Idee dafür?
DB
autor:
id | name
buch:
id | titel
buchautor:
buchID | autorID
app.py:
Code: Alles auswählen
con = sqlite3.connect('bibliothek.db')
cur = con.cursor()
con.text_factory = str
sql3="""INSERT INTO buchautor VALUES (?,?)"""
cur.execute(sql3,(buchID,autorID))
con.commit()
cur.close()
Code: Alles auswählen
<label><br>
Buch: <br>
<select name="buchID" id="buchD">
%for row in rows2:
%txt = u"%s" % (row[1])
<option value ="{{row[0]}}">{{txt}}</option>
%end
</select>
</label>
<br>
<br>
<label>Autor:<br>
<select name="autorID" id="autorID">
%for row in rows1:
%txt = u"%s %s" % (row[1],row[2])
<option value ="{{row[0]}}">{{txt}}</option>
%end
</select>
</label>