[Flask] Passing MySQL values to different webpages

Brian Kim bk at breadtech.com
Fri Mar 11 11:36:05 EST 2016

Hi Stephen,

I believe that the best way to solve your problem will be to pass the data
from page1 into page2 through the URI via GET request. In order to
dynamically set the values, you will probably need to use Javascript. For
example (with JQuery for syntactic convenience...)

<button id="go">Go to Page 2</button>
  $("#go").click( function() {
     target = "/mypage2?" + "key1=" + mydata[0] + "&key2=" + mydata[1]; //
build the URI
     location.href = target; // redirect the page to that URL

def mypage2():
  data1 = request.args.get("key1")
  data2 = request.args.get("key2")
  return render_template("mypage2.html", key1=data1, key2=data2)

This isn't a complete by any means but hopefully gives enough to get you
started... Let me know if you would like a better example and I'll try to
put something up on github for you.


On Fri, Mar 11, 2016 at 10:30 AM, Mazzei, Stephen Andrew <
Stephen.Mazzei at asrcfederal.com> wrote:

> Good morning,
> I am looking for help on a MySQL issue. I am currently running an query
> over a database and populating a table. The table contains items group
> units and then their values. I currently have the group unit as a link to
> that units own webpage.
> On this webpage I would like to repost the same table information, per the
> unit, and then some additional information. How can I pass the query from
> the previous webpage to the next page without having to re-run the same
> query over and over again.
> Thank you
> ---
> Stephen A. Mazzei
> Systems Administrator | AFDS, ASRC Federal Data Solutions - P&G HPC
> Account | 513-634-9965
> ------------------------------
> The preceding message (including attachments) is covered by the Electronic
> Communication Privacy Act, 18 U.S.C. sections 2510-2512, is intended only
> for the person or entity to which it is addressed, and may contain
> information that is confidential, protected by attorney-client or other
> privilege, or otherwise protected from disclosure by law. If you are not
> the intended recipient, you are hereby notified that any retention,
> dissemination, distribution, or copying of this communication is strictly
> prohibited. Please reply to the sender that you have received the message
> in error and destroy the original message and all copies.
> _______________________________________________
> Flask mailing list
> Flask at python.org
> https://mail.python.org/mailman/listinfo/flask
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20160311/01aacc3e/attachment.html>

More information about the Flask mailing list