[Flask] Deleting Flask tables conditionally
spenceryoung at ufl.edu
Mon Mar 6 15:45:59 EST 2017
Suppose you add a record to your `Package` table…
student_id = 12345
new_package = Package()
new_package.student_id = student_id
Now suppose you want to remove that record from your table… You must query and retrieve the record you want to delete, then delete it.
package_to_delete = Package.query.filter_by(student_id=12345).first()
Does that make any sense?
From: Flask <flask-bounces+spenceryoung=ufl.edu at python.org> on behalf of Anonymous Coder <anonymouscodar at gmail.com>
Date: Monday, March 6, 2017 at 1:54 AM
To: Corey Boyle <coreybrett at gmail.com>
Cc: flask <Flask at python.org>
Subject: Re: [Flask] Deleting Flask tables conditionally
I your solution but this isn't working at all to my surprise. I can create rows in tables but I can't delete. I tried a dozen solutions from google. But mine don't work at all. Please advise.
On Sun, Mar 5, 2017 at 11:18 PM, Corey Boyle <coreybrett at gmail.com<mailto:coreybrett at gmail.com>> wrote:
Please clarify... by "table", do you mean "row" or "record"?
Regarding deleteing, I think this line
package = Package()
Needs to be replaced with a query that returns the single object that
you want to delete.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Flask