Python Forum

Full Version: Build a simple Webapp with Python Flask and mariaDB
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I've done a little PHP and Python Programming in the past. Now as a newbie in this field (Thread subject) I want to build a simple webapp for a private purpose and I was wondering how to move forward.
It would be a website listing my family members and when clicking on a family ... we have the details (Family's name, address, phone ...).
I'm working on Ubuntu 20 and I've already installed mariadb and flask(and ran a simple route to see "hello world". Big Grin ).

My concerns are:
- How can I populate my database from my csv file and get the result in the template home.html?
- How to make the result look something like this?

(photo) Family 1
(photo) Family 2
(photo) Family 3
...

and when clicking on a Family, I get

(photo) Family 1
        Name: Family 1
        Address: abc
        Phone: 12345
(photo) Family 2
(photo) Family 3
.
.
.
Any tips/hints/steps and help will really be appreciated
Newbie
What have you tried? Do you know how to read from a CSV file? Do you know how to insert into the database? Have you already installed the MySQL Connector library (see this)? As for templates, have you looked at the docs for Jinja 2 to see how they work?
(May-25-2020, 03:57 AM)ndc85430 Wrote: [ -> ]What have you tried? Do you know how to read from a CSV file? Do you know how to insert into the database? Have you already installed the MySQL Connector library (see this)? As for templates, have you looked at the docs for Jinja 2 to see how they work?
Hi,
thank for replying. I will post a new question with code.
After 44 years in IT and just retiring, I can offer my 2 cents. Always start with a data model and work back from that. Design your tables and normalize as best you can. One table for Family, one for Photos with a foreign key on family_id or something. In my most recent project at home, I wrote a web app to manage our LP, CD, and DVD collection. It wasn't drill-down like yours but it does allow editing a record by clicking on a grid. Used Flask for the REST api (with MySQL) a,d Svelte for the GUI. All hosted by Ubuntu 20.x. Developed on Win10.