This a flask app that I am connecting to the mysql 

@app.route("/viewSingle", methods=['POST','GET'])
def SingleView():
    formB=singleView()
    data=[]
    if request.method=="POST":
        if formB.validate_on_submit:
        #if request.form['submit']=="View CONTINENT":
            c,conn = connection()
            c.execute('''select * from Country''')
            data = c.fetchall()
            data=list(data)
            for row in data:
                for a in row:
                    return row  //this is the problem
            #return str(data) 
            #data=list(data)
            c.close ()
            conn.close ()
            #return data
    return render_template("view.html",data=data,formB=formB)

error 
ValueErrorValueError: too many values to unpackTraceback (most recent call 
last)File 
"/home/isaac/flasky/project_1/lib/python2.7/site-packages/flask/app.py", line 
1836, in __call__return self.wsgi_app(environ, start_response)File 
"/home/isaac/flasky/project_1/lib/python2.7/site-packages/flask/app.py", line 
1820, in wsgi_appresponse = self.make_response(self.handle_exception(e))File 
"/home/isaac/flasky/project_1/lib/python2.7/site-packages/flask/app.py", line 
1403, in handle_exceptionreraise(exc_type, exc_value, tb)File 
"/home/isaac/flasky/project_1/lib/python2.7/site-packages/flask/app.py", line 
1817, in wsgi_appresponse = self.full_dispatch_request()File 
"/home/isaac/flasky/project_1/lib/python2.7/site-packages/flask/app.py", line 
1478, in full_dispatch_requestresponse = self.make_response(rv)File 
"/home/isaac/flasky/project_1/lib/python2.7/site-packages/flask/app.py", line 
1563, in make_responserv, status, headers = rv + (None,) * (3 - 
len(rv))ValueError: too many values to unpack


> From: d...@hashcollision.org
> Date: Tue, 19 Apr 2016 15:01:41 -0700
> Subject: Re: [Tutor] List of tuples
> To: itette...@hotmail.com
> CC: tutor@python.org
> 
> On Tue, Apr 19, 2016 at 1:56 PM, isaac tetteh <itette...@hotmail.com> wrote:
> > I have a list like this
> > [
> > ("name",2344,34, "boy"),("another",345,47,"boy", "last")
> > ]
> > How do u get each value from it like
> > Output
> > name
> > 2344
> > 34
> > ...
> >
> > What i did was
> > for row in list_tuple:
> >     for row2 in row:
> >         return row
> >
> > But i get error  too many value to unpack
> 
> 
> Hi Issac,
> 
> Can you copy and paste the exact error message and stack trace that
> you're seeing?  Try not to paraphrase it: we need to see exactly the
> text is saying.  In some cases, we'll even pay attention to whitespace
> and other insanely silly details.  :P
> 
> Since that's tedious for you to retype, just use copy-and-paste.
> Include everything that the error message says, even if it doesn't
> make sense to you.  We'll try to help you interpret what the error is
> saying.  Unfortunately, you paraphrased the error message above too
> much: I have no good guesses from what you've presented so far.
> 
> Also, try to show the entire program that you ran as well.  The
> snippet you showed us is incomplete, because we don't know how the
> program defines "list_tuple".  Generally, you want to include enough
> detail when asking for help that it's really easy for the tutors here
> to "reproduce" your problem.  That way, we can see the same problem
> that you see.  That's important.
> 
> 
> My best guess so far, from all that you've shown us, is that a
> *different* part of the program is responsible for the error you're
> showing us.  That's why we need more details: I think something else
> other than what you're showing us is producing that error.  The reason
> I think so is because no part of the program you're showing us is
> doing tuple unpacking, at least from what I can tell.
                                          
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to