This blog post is brought to you by the developer of BitBudget. BitBudget is an automated budgeting app for Android and iOS which syncs with your bank account and helps you avoid overspending. If you’d like to quit living paycheck-to-paycheck and get a better handle on your finances, download it today! https://bitbudget.io
Just wanted to bookmark a great tutorial on: Creating a Web App From Scratch Using Python Flask and MySQL. Coming from a LAMP Stack background, I’d really like to keep using MySQL, so that’s what I plan on playing around with over the next couple days. Learning Python/Flask is coming along fairly well, and I think I’m almost to the point where I can actually start building some stuff.
UPDATE (3/20/2019): Made some good progress getting MySQL all setup on my local Windows 10 development machine tonight. Note to self– pick back up with the tutorial tomorrow @ Step 1: Setting Up the Database
UPDATE (3/20/2019): Pick back up @ Step 3: Implement a Signup method
UPDATE (3/21/2019): Resume tutorial @ Step 5: Call the MySQL Stored Procedure
CONCLUSION (3/21/2019): So I just finished the above tutorial, but unfortunately received an error when attempting to actually insert data into my MySQL database. I think the problem likely has something to do with “stored procedures.” I’ve never actually used a “stored procedure” before and honestly don’t really even know what it is or why I would want one, but… I think the tutorial was helpful. My main takeaway from the whole thing was that I should look more into this library called Flask-MySQL so I can really get this figured out. Right now I have two big things I need to learn:
- Using MySQL with Python & Flask
- Deploying my Flask Project Code to a Live Server Running Apache Web Server Software Instead of the Built-In Development Flask Server
FURTHERMORE (3/21/2019): There appear to be multiple python/mysql libraries, so I might check some of those out as well.
YET ANOTHER UPDATE (3/22/2019): I figured out how to INSERT data into my MySQL database using the mysql.connector Python library. Here is a link to my example webapp: Flask-Plus-MySQL
Right now the demo app only shows how to INSERT data into the database. However, I will make sure to improve the demo tomorrow so that it also shows how to SELECT data from the database and then display the data using a Jinja2 template.
LAST UPDATE (3/22/2019): Finished adding some code to the example app which demonstrates how to SELECT data from a MySQL database using Python (and Flask) and then present that data back to the user using the Jinja2 templating engine.