You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2020/11/19 14:03:21 UTC
[GitHub] [skywalking] alonelaval commented on issue #5865: [Python] Not getting db data while using pymysql or pymongo inside flask server
alonelaval commented on issue #5865:
URL: https://github.com/apache/skywalking/issues/5865#issuecomment-730396382
You need to know the order in which python modules are loaded. @rohan2546

`import pymysql.cursors
from flask import Flask, request
from skywalking import agent, config
from skywalking.trace.context import SpanContext, get_context
app=Flask(__name__)
@app.route('/getDoctor',methods=['GET','OPTIONS'])
def addProblem():
if request.method == 'GET':
context: SpanContext = get_context()
connection = pymysql.connect(
host="localhost",
user="root",
password="root123",
database="test")
with connection.cursor() as cursor:
sql = "SELECT `*` FROM `doctors`"
cursor.execute(sql)
result = cursor.fetchone()
connection.close()
a= ''
for x in result:
a=a+str(x)
return a,201
# return myresult,201
if __name__ == '__main__':
config.service_name = 'service5'
config.logging_level = 'DEBUG'
config.mysql_trace_sql_parameters = True
agent.start()
app.run(debug=True,port=8999)`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org