tadamhicks tadamhicks - 7 months ago 109
SQL Question

Run Cx_Oracle query in Flask App

I am trying to build an app that has a page where I input an id and run a query on that and show results. Code I have so far is below.

I keep a werkzeug error:

BuildError: ('show_entries', {}, None)


app.py

import cx_Oracle

# Run the query to display the results
@app.route('/matcher/<int:account_id>', methods=['GET', 'POST'])
def show_entries(account_id):
sql = """SELECT item1,
item2,
item3,
item4,
item5,
item6
FROM TABLE
WHERE account_id = ?"""
c = g.db.cursor()
c.execute(sql, account_id)

Answer

The addition that makes this work is here. Everything else in my original code is fine, even if not optimal.

        c.execute(sql, account_id=account_id)