I have a function that get records from the database then returns the JSON format
@app.route("/endpoint/customers",methods=["POST"])
def test():
if request.method == "POST":
user_id = request.form.get('id')
g.db = MySQLdb.connect(host="xxxxxx", user="xxxxxx", passwd="xxxxxx", db="xxxxx", cursorclass=MySQLdb.cursors.DictCursor)
g.db.autocommit(True)
cur = g.db.cursor()
cur.execute("SELECT id, first_name, last_name, pin, destination, origin, did, mode, comment, posauthnum, amount, paydate, created_by, flag, balance, cashtype, CONVERT(start_date, DATE) as start_date, CONVERT(end_date, DATETIME) as end_date, CONVERT(created_date, DATETIME) as created_date FROM customers WHERE created_by=%s", (user_id))
destinations = cur.fetchall()
g.db.close()
return jsonify(destinations)
This is working well on my local machine but it throws an error 500 on Heroku and CentOS server. The bad part is I do not know where to view error logs on CentOS. On the server when I replace jsonify(destinations) with a return 1 or any other character. It works without any error 500. So I guess the issue is the jsonify(destinations) but the weird thing is it is working on my localhost.
So I did pip freeze to check all packages that I have installed
alabaster==0.7.9
anaconda-clean==1.0
anaconda-client==1.5.1
anaconda-navigator==1.3.1
argcomplete==1.0.0
astroid==1.4.7
astropy==1.2.1
Babel==2.3.4
backports-abc==0.4
backports.shutil-get-terminal-size==1.0.0
backports.ssl-match-hostname==3.4.0.2
beautifulsoup4==4.5.1
bitarray==0.8.1
blaze==0.10.1
blinker==1.4
bokeh==0.12.2
boto==2.42.0
Bottleneck==1.1.0
cdecimal==2.3
cffi==1.7.0
chest==0.2.3
click==6.6
cloudpickle==0.2.1
clyent==1.2.2
colorama==0.3.7