Working with Python-Flask-MySQL

$ python -V
$ pip install -r pymysql$ pip install -r Flask$ pip install -r Flask-cors$ pip install -r simpleJson
DB_CONF = {'host':'<YOUR-MYSQL-HOST>','port':3306,'user':'<YOUR-MYSQL-USERNAME>','passwd':'<YOUR-MYSQL-PASSWORD>','db':'<YOUR-MYSQL-DATABASE>'}In main.py, put your real query like this,sql="<PUT YOUR MySQL QUERY HERE>"eg.
@app.route(‘/testWebService’)
def test_get():
# create mysql connection
Conn = pymysql.connect(host=config.DB_CONF[‘host’],
port=config.DB_CONF[‘port’],
user=config.DB_CONF[‘user’],
passwd=config.DB_CONF[‘passwd’],
db=config.DB_CONF[‘db’])
cur = conn.cursor()
sql="<PUT YOUR MySQL QUERY HERE>"
cur.execute(sql)
For Python3,$ gunicorn3 --log-level debug --bind 0.0.0.0:30443 server:app
$ gunicorn3 --workers=3 --bind 0.0.0.0:3000 main:app
$ sudo fuser -k 3000/tcp
$ ./sampleWebService.sh

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store