I am using flask and mysql I want to get values from different tables of my base in some select if someone knows how I can do them please:
@app.route("/tipo_cuenta")
def tipo_cuenta():
cur = mysql.connection.cursor()
cur.execute("SELECT * FROM tipo_cuenta")
rv = cur.fetchall()
cur.close()
return render_template("tipo_cuenta.html", periodo=rv)
<form action="{{ url_for('tipo_cuenta') }}">
<div class="form-group">
<label for="" id="label1">SELECCIONE EL TIPO DE CUENTA</label>
<select class="form-control" id="tipo_cuenta_idtipo_cuenta" name="tipo_cuenta_idtipo_cuenta" method="POST" action="/">
{% for tipo_cuenta_idtipo_cuenta in periodo%}
<option value="{{ tipo_cuenta_idtipo_cuenta[1] }}">{{ tipo_cuenta_idtipo_cuenta[1] }}</option>
{% endfor %}
</select>
</div>
I get the desired combo now I want to get data from the same base but from another table in another select but it doesn't work for me what should I do to make it work
@app.route("/tipo_cuenta")
def tipo_cuenta():
cur = mysql.connection.cursor()
cur.execute("SELECT * FROM tipo_cuenta")
rv = cur.fetchall()
cur.close()
cur2 = mysql.connection.cursor()
cur2.execute("SELECT * FROM cursos")
rv2 = cur2.fetchall()
cur2.close()
cur3 = mysql.connection.cursor()
cur3.execute("SELECT * FROM jornada")
rv3 = cur3.fetchall()
cur3.close()
return render_template("tipo_cuenta.html",
periodo=rv,periodo2=rv2,periodo3=rv3)