Re: Setting the encoding in pysqlite2

2005-08-25 Thread Renzo
Michele Simionato ha scritto:
> An easy question, but I don't find the answer in the docs :-(
> I have a sqlite3 database containing accented characters (latin-1).
> How do I set the right encoding? For instance if I do this:
> 

Hi,
i usually use this "string" method:

encode([encoding[,errors]])

An example:

cur.execute("""
insert into tab(
field1,
field2)
 values (?,?)
 """ , (myvar1.encode('utf8'),\
myvar2.encode('utf8')))

Bye,
Renzo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: zipfile library - problem..

2005-08-11 Thread Renzo
Renzo ha scritto:

I've seen that the error is a known bug:

"zipfile still has 2GB boundary bug"
<http://mail.python.org/pipermail/python-dev/2005-April/052887.html>

so I've used the module TarFile instead ZipFile, and now the script 
works perfectly.

Thanks to Deelan and Manlio Perillo (i.c.l.p.)

Renzo
-- 
http://mail.python.org/mailman/listinfo/python-list


zipfile library - problem..

2005-08-11 Thread Renzo
Hi,
I'm working to create a backup function for a software; in particular, 
from a directory with 12300 files (Jpg, medium size = 250KB / total size 
= 2.90GB), i have to create a zip file.

I've decided to use the standard "zipfile" library to do that.
This is the code:

zipName = path.join(config.get('server.xbakPath'), 'backup.zip')
fileExport = zipfile.ZipFile(zipName,'w',zipfile.ZIP_DEFLATED)

#Insert images
listaImg = listdir( config.get('server.iPath') )
for file in listaImg:
 if not path.isdir(path.join(config.get('server.iPath'), file)):
 fileExport.write(path.join(config.get('server.iPath'), file), \
  file)

#close ZIP
fileExport.close()

Unfortunately, after few minutes, i see this error message:
Traceback (most recent call last):
   File "C:\Python24\Lib\site-packages\cherrypy\_cphttptools.py", line
256, in run
 main()
   File "C:\Python24\Lib\site-packages\cherrypy\_cphttptools.py", line
452, in main
 body = func(*(virtualPathList + cherrypy.request.paramList),
   File "C:\pagine\utilities.py", line 162, in exportdati
 fileExport.close()
   File "C:\Python24\lib\zipfile.py", line 503, in close
 zinfo.header_offset)
OverflowError: long int too large to convert to int

Reading the error I've known that the error is generated calling
"fileExport.close()", that calls the zipfile module,
and into that module there is an exception.

For information: when code stops, the zip file has size = 3.177.950.237 
byte, but this size doesn't exceed ZIP limits:

the limits of ZIP files according to the folks who make info-zip:
http://www.info-zip.org/pub/in fozip/FAQ.html#limits

  statistic limit
number of files65,536
uncompressed size of a single file   4 GB
compressed size of a single file 4 GB
total size of archive  256 TB
maximum path/filename length64 KB

Have you any idea?
Oh, the O.S. is WinXP Pro

Thank you!.
Renzo
-- 
http://mail.python.org/mailman/listinfo/python-list