Answers

Question and Answer:

  Home  Python Developer

⟩ Explain me database connection in Python Flask?

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.

 129 views

More Questions for you: