2

I am using the flask and flask_restplus to build an rest api in python. The directory structure i followed is same in the link below under the heading Multiple APIs with reusable namespaces

https://flask-restplus.readthedocs.io/en/stable/scaling.html

Now I am trying to add mySql database connection and for that I used the following code in app.py

from flaskext.mysql import MySQL
mysql = MySQL()
app.config['MYSQL_DATABASE_USER'] = 'name'
app.config['MYSQL_DATABASE_PASSWORD'] = 'test'
app.config['MYSQL_DATABASE_DB'] = 'textclassifier'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'
mysql.init_app(app)

I tried using mysql object through

from app import mysql 

which is wrong, i read the whole document but I could not find a way to add the mysql connection without changing the structure.

Does anyone has an idea how i can solve this ? I am new to flask and rest api in python

niharika Singhal
  • 61
  • 1
  • 1
  • 10

0 Answers0