Python Developer Question:

Download Job Interview Questions and Answers PDF

Explain me database connection in Python Flask?

Python Developer Interview Question
Python Developer Interview Question

Answer:

Flask supports database powered application (RDBS). Such system requires creating a schema, which requires piping the shema.sql file into a sqlite3 command. So you need to install sqlite3 command in order to create or initiate the database in Flask.

Flask allows to request database in three ways

before_request() : They are called before a request and pass no arguments
after_request() : They are called after a request and pass the response that will be sent to the client
teardown_request(): They are called in situation when exception is raised, and response are not guaranteed. They are called after the response been constructed. They are not allowed to modify the request, and their values are ignored.

Download Python Developer Interview Questions And Answers PDF

Previous QuestionNext Question
Please explain what are the rules for local and global variables in Python?Explain me what are the key features of Python?