In my SQL table I stored the
postal_code as INTEGER and
place_name as TEXT. So whenever I type a number or text, it will match accordingly. The problem is that I'm not getting anything as JSON output.
Here's my code:
@app.route("/search") def search(): """Search for places that match query.""" a =  q = request.args.get("q") #ex q= "Boca Raton, Florida, 33496" if type(q) == int: q = str(q) + "%" a= db.execute("SELECT * FROM places WHERE postal_code LIKE :q", q=q) elif type(q) == str: q += "%" a= db.execute("SELECT * FROM places WHERE place_name LIKE :q", q=q) return jsonify(a)
Output when testing with https://ide50-tadm123.cs50.io/search?q=33496:
Anyone know what I'm doing wrong? Really would appreciate any help. Thanks.
Edit: Here's a single row of my SQL table if anyone is wondering: