Psycopg2.errors.InvalidTextRepresentation ⇐ Python
-
Anonymous
Psycopg2.errors.InvalidTextRepresentation
i'm trying to run a raw sql query in a flask application. here is what i have
@app.route("/price/compare",methods=["POST"]) def post(): data= request.json cur = conn.cursor() query_stock = """SELECT name,size,MIN(price::float) as price,link FROM product WHERE name like '%{0}%' AND size='{1}' GROUP BY price,name,size,link """.format(data["name"],data["size"]) stock_r={} try: cur.execute(query_stock) stock_r=cur.fetchone() except Exception as e: raise e print(e) print("ERROR : ", str(e)) stock_r={} return jsonify({"stock_site":stock_r,"goat_site":goat_r}) when i make a post request to the route i get the following error
return super(RealDictCursor, self).execute(query, vars) psycopg2.errors.InvalidTextRepresentation: invalid input syntax for type double precision: ""
what am i doing wrong?
Источник: https://stackoverflow.com/questions/609 ... esentation
i'm trying to run a raw sql query in a flask application. here is what i have
@app.route("/price/compare",methods=["POST"]) def post(): data= request.json cur = conn.cursor() query_stock = """SELECT name,size,MIN(price::float) as price,link FROM product WHERE name like '%{0}%' AND size='{1}' GROUP BY price,name,size,link """.format(data["name"],data["size"]) stock_r={} try: cur.execute(query_stock) stock_r=cur.fetchone() except Exception as e: raise e print(e) print("ERROR : ", str(e)) stock_r={} return jsonify({"stock_site":stock_r,"goat_site":goat_r}) when i make a post request to the route i get the following error
return super(RealDictCursor, self).execute(query, vars) psycopg2.errors.InvalidTextRepresentation: invalid input syntax for type double precision: ""
what am i doing wrong?
Источник: https://stackoverflow.com/questions/609 ... esentation