From: Alan L. <al...@ja...> - 2005-10-14 01:27:14
|
Well, I must be just having a bad day. Still exploring SQLObject which look= s really nice but is giving me grief: SQLlite/SQLObject 0.7/pysqlite2/WindowsXP 1) create a connection hub: sqlhub.processConnection =3D connectionForURI(self.connection_string) [works fine -- can create tables etc] 2) Define a MediaFile class: class MediaFile(SQLObject) artist =3D StringCol(default =3D "Unknown Artist") title =3D StringCol(default =3D "Unknown Title") album =3D StringCol(default =3D "Unknown Album") 3) For a given artist and title look to see if they are in the DB: record =3D mediamanager.MediaFile.selectBy(artist=3Dartist, title=3Dtitle) if record.count() > 0: ...... when I get to the record.count() we get an exception: [SQLite objects created in a thr ead can only be used in that same thread.The object was created in thread i= d 314 4 and this is thread id 492] Traceback (most recent call last): File "C:\usr\projects\new-jacknyfe\switchback\mediaprocessor\localfiles.p= y", l ine 27, in process_files if record.count() > 0: File "c:\python23\lib\site-packages\SQLObject-0.7.0-py2.3.egg\sqlobject\s= resul ts.py", line 182, in count count =3D self.accumulate('COUNT(*)') File "c:\python23\lib\site-packages\SQLObject-0.7.0-py2.3.egg\sqlobject\s= resul ts.py", line 166, in accumulate return conn.accumulateSelect(self, *expressions) File "c:\python23\lib\site-packages\SQLObject-0.7.0-py2.3.egg\sqlobject\d= bconn ection.py", line 380, in accumulateSelect val =3D self.queryOne(q) File "c:\python23\lib\site-packages\SQLObject-0.7.0-py2.3.egg\sqlobject\d= bconn ection.py", line 740, in queryOne return self._dbConnection._queryOne(self._connection, s) File "c:\python23\lib\site-packages\SQLObject-0.7.0-py2.3.egg\sqlobject\d= bconn ection.py", line 338, in _queryOne c =3D conn.cursor() ProgrammingError: SQLite objects created in a thread can only be used in th= at sa me thread.The object was created in thread id 3144 and this is thread id 492 .. Have Googled up the Wazoo and poured over what little SQLObject docs I can = find but the problem is not leaping up at me. It _is_ true that that class = MediaFile is defined in one thread (the initialization thread) and the sele= ct is done in another (a timer thread). But surely the class definition doe= sn't rely on thread local storage (?). Sorry to say I am flummoxed. A gentl= e pointer would really help. TIA Alanl |