2007年09月28日 星期五 13:29
Yingbo Qiu,您好!
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Python25\lib\threading.py", line 460, in __bootstrap
self.run()
File "C:\Python25\lib\threading.py", line 440, in run
self.__target(*self.__args, **self.__kwargs)
File "D:\s.py", line 22, in select
conn.execute("select * from testtbl")
ProgrammingError: SQLite objects created in a thread can only be used in that sa
me thread.The object was created in thread id 4108 and this is thread id 4120
如果多线程使用一个连接就会报这个错误。
所以只能每个线程都自己创建一个连接。
======= 2007-09-28 11:11:39 您在来信中写道:=======
>在 07-9-28,赵威<zhaowei在pythonid.com> 写道:
>> hawk gao,您好!
>>
>> 我现在觉得在python里用sqlite很不爽,第一个是utf-8的问题,sqlite3只能存储utf-8的。
>> 还有一个更不爽的问题,是居然不能在多线程里用
>
>是怎么不能在多线程环境里用呢?
>_______________________________________________
>python-chinese
>Post: send python-chinese在lists.python.cn
>Subscribe: send subscribe to python-chinese-request在lists.python.cn
>Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn
>Detail Info: http://python.cn/mailman/listinfo/python-chinese
= = = = = = = = = = = = = = = = = = = =
致
礼!
赵威
zhaowei在pythonid.com
2007-09-28
2007年09月28日 星期五 13:34
多线程使用一个连接并不是不可以。你可以看看文档,把那个检测线程的去掉。但是关键是你不用同时使用。 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://python.cn/pipermail/python-chinese/attachments/20070928/9469663c/attachment.htm
Zeuux © 2025
京ICP备05028076号