------------------------------------------
gbk也不行...
self.string_standard_db_connect = sqlite.connect(filepath.encode('cp936'))
:
pysqlite2.dbapi2.OperationalError: unable to open database file
--
I like python!
UliPad <<The Python Editor>>: http://code.google.com/p/ulipad/
My Blog: http://www.donews.net/limodou
数据 文件名当然不会起个中文名.
filepath 就是 unicode
filepath.encode('cp936') 个 是gbk
所以 都不行.
On 9月7日, 下午12 02分, limodou <limo...@gmail.com> wrote:
> On 9/7/07, chunlin zhang <zhangchun...@gmail.com> wrote:
>
> > unicode是不行的...
> > self.string_standard_db_connect = sqlite.connect(filepath)
> > :
> > self.string_standard_db_connect = sqlite.connect(filepath)
> > UnicodeEncodeError: 'ascii' codec can't encode characters in position
> > 34-35: ordinal not in range(128)
>
> > ------------------------------------------
> > gbk也不行...
>
> > self.string_standard_db_connect = sqlite.connect(filepath.encode('cp936'))
> > :
> > pysqlite2.dbapi2.OperationalError: unable to open database file
>
> 数据 文件名 用了中文?使用unicode .
so,I have to use english.
my db file name is english,there is no chinese char...
but when i copy app dir to "desktop",there is chinese char("桌面",like
C:\Documents and Settings\zhangcl\桌面\t ) in the full db path,because i
get the abs path of db file using os.join(appdir,"my.db").
你可以简单加一段::
import sys
reload(sys)
sys.setdefaultencoding('gb18030')
如果你的 windows 版本不支持 gb18030 , 就用 mbcs 代替。
在 07-9-7,chunlin zhang<zhangc...@gmail.com> 写道:
我觉得是pysqlite的问题.
C:\Documents and Settings\zhangclb\桌面\mtk.ref_list\ref_list.db
Traceback (most recent call last):
File "D:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 1409
9, in <lambda>
lambda event: event.callable(*event.args, **event.kw) )
File "C:\Documents and Settings\zhangclb\桌面\mtk.ref_list\ref_list_sync.py",
line 44, in on_initialize
self.string_standard_db_connect = sqlite.connect(filepath.encode('cp936'))
pysqlite2.dbapi2.OperationalError: unable to open database file
算了,这个不解决也没关系.发布的时候说明一下.
或者写段代码检查一下路径是否有中文,如果有中文就提示错误吧.
On 9/7/07, limodou <lim...@gmail.com> wrote:
>>> import sqlite3
>>> con = sqlite3.connect('/tmp/中文/目录/文件.db')
>>>
是不是你的版本有问题?
在 07-9-7,chunlin zhang<zhangc...@gmail.com> 写道:
> 目录不用中文没问题的.
> 我这个工具已经完成了,但是发现拷到桌面上就用不了.
谢谢jiahua!
On 9/7/07, Jiahua Huang <jhuang...@gmail.com> wrote:
在 07-9-7,chunlin zhang<zhangc...@gmail.com> 写道:
> 呀,提醒我了,我改成
> sqlite.connect(filepath.encode('utf8'))
> 就好了.所以sqlite里都要用utf8的
> 里面的sql语句和数据等等都用 utf8 的,结果把这里给忘了.
>
> 谢谢jiahua!
>
> On 9/7/07, Jiahua Huang <jhuang...@gmail.com> wrote:
> > 这 utf8 环境下中文路径、文件名都没有问题的
> >
> > >>> import sqlite3
> > >>> con = sqlite3.connect('/tmp/中文/目录/文件.db')
> > >>>
> >
> > 是不是你的版本有问题?
> >
> > 在 07-9-7,chunlin zhang<zhangc...@gmail.com> 写道:
> > > 目录不用中文没问题的.
> > > 我这个工具已经完成了,但是发现拷到桌面上就用不了.
>
> >
>
--
Hiweed-Debian
pgpkey: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x5B6F0C29