9월, 2020의 게시물 표시

Python Flask - MySQL connection using SQLAlchemy

이미지
I have referenced a lot on Mike Driscoll's blog https://www.blog.pythonlibrary.org/ ,   Flask 101: Adding a Database Flask 101: How to Add a Search Form Flask 101: Adding, Editing and Displaying  Recently, I had to install MySQL on Odroid XU4 SBC and connect it remotely.  I really hate GUI programming. I love the cli interface. However, to provide a simple GUI interface for simple table lookup, modification,, I decided to create a web page using Flask. I will skip the content of installing MySQL. You will find numerous explanations for this on the Internet. I'm going to use SQLAlchemy, I thought it was nice that there is a ready-made extension for adding SQLAlchemy to Flask called Flask-SQLAlchemy . SQLAlchemy can link not only MySQL but also lightweight DB such as SQLite and RDBMS such as PostgreSQL. All the work below was done by Ubuntu 18.04 on Odroid XU-4. Prerequisites Several blogs have explained how to implement Flask. Python Flask - Running a simple web s...

Python return code

Check Python Return Code at C/C++ Usually, the sys.exit() function is used to specify the return value of the Python program.   sys. exit ( [ arg ] ) Exit from Python. This is implemented by raising the SystemExit exception, so cleanup actions specified by finally clauses of try statements are honored, and it is possible to intercept the exit attempt at an outer level. The optional argument arg can be an integer giving the exit status (defaulting to zero), or another type of object. If it is an integer, zero is considered “successful termination” and any nonzero value is considered “abnormal termination” by shells and the like. Most systems require it to be in the range 0–127, and produce undefined results otherwise. Some systems have a convention for assigning specific meanings to specific exit codes, but these are generally underdeveloped; Unix programs generally use 2 for command line syntax errors and 1 for all other kind of errors. If another type of object is passed...