I have been working on this pset for two weeks now and cannot figure out the search function. (I skipped it and moved on) I have no idea why this function is not working or if it is working just my other code is wrong.
When I use the link to check your function in the specification (https://ide50-username.cs50.io/search?q=02138) I am returned an empty set --> [ ]. I cannot figure out why and I have tried everything!!
Here is my code:
@app.route("/search") def search(): """Search for places that match query.""" # get q q = request.args.get("q") + "%" #select q from table place = db.execute("SELECT * FROM places WHERE postal_code LIKE :q", q=q) #reuturn results -- TEN MAX if len(place) > 10: return jsonify([place, place, place,place, place, place, place, place, place, place]) else: return jsonify(place)
UPDATE: I imported the database with the commands shown in the specification.
$ sqlite3 mashup.db .separator "\t" .import US.txt places
I currently have places as a table in mashup. Here is a screenshot of what it looks like:
Does this look correct?