1

Here is my code for application.py pset8 search route which always returns 0 or empty array, I can't figure out why, Kindly help

@app.route("/search", methods=["GET", "POST"])
def search():
"""Search for places that match query."""
""" If method used is not Get raise error"""
if request.method != "GET":
    raise RuntimeError ("Use get request method")
else:
    q = request.args.get("q") + "%"
    place = db.execute("SELECT * FROM places WHERE postal_code LIKE :q", q=q)
return jsonify(place)

This code's raw data returns [] I have changed the code, But my first problem is the empty array returned from the data base. The empty code array is taken from Raw Data.

8
  • 1
  • Sir I have explained my question again please have a look I have changed last line of jsonify, but main problem is my code is returning empty array as I have edited in the code.
    – Ahmed Raza
    Jun 20, 2017 at 12:47
  • 1
    Suspect postal_code is INTEGER (or some numeric type) in the database. Change to duplicate of 24075. Jun 20, 2017 at 12:53
  • Yes it is INTEGER in data base what datatype should I use, and what data type to be used for text fields like "place_name" I even tried to query these text fields from phpliteadmin but the data base could only find with data type INTEGER not with data type TEXT like place name.
    – Ahmed Raza
    Jun 20, 2017 at 13:01
  • 1
    Sorry, forgot to include the link From the posted code it is unclear how "Cambridge" would return anything. Jun 20, 2017 at 13:11

0

You must log in to answer this question.

Browse other questions tagged .