def query_id(request): request.encoding = 'utf-8' if 'query' in request.GET and request.GET['query']: query = request.GET['query'] cursor = connection.cursor() sql = "SELECT id, name FROM xss_userbasic WHERE id =" + query cursor.execute(sql) ctx = {} row = cursor.fetchall() ctx['rlt'] = row return render(request, "xss/task1.html", ctx)