I am making a website with Flask and I am trying to create a dropdown menu filled with all regions in the regions table from my postgres database. Currently I have hardcoded the dropdown like this:
<label for="regions">Choose a region:</label>
<select name="regions" id="regions">
<option value="murray">Murray</option>
<option value="darling">Darling</option>
<option value="coast">Coast</option>
<option value="central">Central</option>
</select>
However, I would like to change this so that the dropdown is populated based off of an sql query of the table with all regions. Is this possible?
The SQL Query for the names of all the regions is:
select region_name from regions
pycopg2to connect to your postgres database. https://www.postgresqltutorial.com/postgresql-python/connect/ for reference.