Re: difference between statements

"Eric S. Johansson" <[email protected]>
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
Martin Jenkins wrote:
> Eric S. Johansson wrote:
> 
>> test code:
>> http://pastebin.ca/413572
>>
> 
> Slightly fixed code:)
> http://pastebin.ca/413830

Thank you so very much.  You've provided some enlightenment with regard 
to Python and sqlite.  However, I took your code almost entirely as it 
is (changed the import statement) and I get

esj@camram606:~/projects/tpblue/tpblue$ sudo python 413830.py

--------------------------------------------------------------------------------
Regenerating data
   Deleting users where internal_ID='esj'
     Inserting '[email protected]' with internalID 'esj'
     Inserting '[email protected]' with internalID 'esj'
   Deleting users where internal_ID='xqp'
     Inserting 'test1-Vfh7fEhEWOlaa/[email protected]' with internalID 'xqp'
     Inserting 'test2-Vfh7fEhEWOlaa/[email protected]' with internalID 'xqp'
     Inserting 'test3-Vfh7fEhEWOlaa/[email protected]' with internalID 'xqp'
   Deleting users where internal_ID='linus'
     Inserting '[email protected]' with internalID 'linus'
     Inserting '[email protected]' with internalID 'linus'

Regrouping data
Traceback (most recent call last):
   File "413830.py", line 294, in ?
     main2()
   File "413830.py", line 267, in main2
     print "  regroup: '%s' - result '%s'" % (intID, ts.regroup(intID))
   File "413830.py", line 238, in regroup
     rs = [r[0] for r in candidates.fetchall()]
AttributeError: 'NoneType' object has no attribute 'fetchall'
esj@camram606:~/projects/tpblue/tpblue$

the culprit method is...

     def regroup(self, internal_ID):
         """given a single ID, get all names """
         select_cmd = "select external_ID from external_internal where 
(internal_ID=?)"
         candidates = self.cursor.execute(select_cmd,(internal_ID,))

         # MJ: this gets rid of the "list of tuples" ugliness
         rs = [r[0] for r in candidates.fetchall()]
         return rs

Martin, you have been wonderfully helpful and I am so very grateful. 
But at this point, I'm about ready to ditch pysqlite because I have 
spent way too much time fighting with this toolkit.  It is only 
reinforced my impression that it was a good decision to avoid working 
with databases for the past 30 years.

would be any easier to work with apsw (3.2.7r1-1).

---eric

-- 
Speech-recognition in use.  It makes mistakes, I correct some.
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.