Re: ValueError: too many values to unpack

[email protected]
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <OF37727B09.3D607600-ON85257236.006B73AC-85257236.006B92F3@bankofny.com>
The other possibility is that you have more rows than the 5 you are
returning, that is why select *  is bad, you should do a select
model_desc, model_type, keName, agent from tablename

Thanks,

Greg Givler
Information Technology
Lockwood®
10 Valley Stream Parkway
Malvern, PA 19355
Phone: (484) 605-4826
Email: [email protected]


                                                                                                                                           
                      Rich Shepard                                                                                                         
                      <rshepard@appl-ecosys        To:       [email protected]                                                      
                      .com>                        cc:                                                                                     
                      Sent by:                     Subject:  [pysqlite] ValueError: too many values to unpack                              
                      pysqlite-bounces@list                                                                                                
                      s.initd.org                                                                                                          
                                                                                                                                           
                                                                                                                                           
                      11/30/2006 02:26 PM                                                                                                  
                      Please respond to                                                                                                    
                      Rich Shepard; Please                                                                                                 
                      respond to "For users                                                                                                
                      of the pysqlite                                                                                                      
                      database module."                                                                                                    
                                                                                                                                           
                                                                                                                                           




   My application has a table named 'model' with this schema:

CREATE TABLE model (model_name TEXT NOT NULL PRIMARY KEY,
model_desc TEXT, model_type TEXT, keName TEXT, agent INTEGER);

and it holds one record.

   During testing I created a new database and inserted values in each
of
these fields. But, when I open the existing database to read each column
and
insert the values in the appropriate GUI widgets, I get the error
message on
the subject line:

   File "/data1/eikos/modelPage.py", line 198, in OnOpenMod
     for (model_desc, model_type, keName, agent) in self.appData.cur:
ValueError: too many values to unpack

   What I'm trying to do in this method (starting at line 197) is,

     self.appData.cur.execute("select * from model")
     for (model_desc, model_type, keName, agent) in self.appData.cur:
       modDesc = model_desc
       mType = model_type
       knowlEng = keName
       method = agent
     self.tcDesc.SetValue(modDesc)
     self.modType.SetString(self.modType.SetSelection(mType))
     self.keName.SetValue(knowlEng)
     self.agent.SetSelection(method)

   My newness to pysqlite is undoubtably the reason why I have the
syntax
incorrect, and I did read the appropriate section in the on-line doc on
how
to extract each table record into a local variable. I thought the 'for
...'
loop syntax was appropriate when there's a single record, and I did not
need
to use fetchone(). What is the appropriate syntax?

Rich

--
Richard B. Shepard, Ph.D.               |    The Environmental
Permitting
Applied Ecosystem Services, Inc.(TM)    |            Accelerator
<http://www.appl-ecosys.com>     Voice: 503-667-4517      Fax:
503-667-8863
_______________________________________________
pysqlite mailing list
pysqlite-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/pysqlite

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please call the help desk at ext 4850
______________________________________________________________________




______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.