escape binary data

This commit is contained in:
j 2009-08-21 17:18:03 +02:00
parent f691867e1d
commit 18383a88b0
2 changed files with 4 additions and 2 deletions

2
README
View file

@ -16,6 +16,8 @@ Usage:
oxlib.formatBytes(1234567890)
'1.15 GB'
Install:
python setup.py install
Tests:
nosetests --with-doctest oxlib

View file

@ -167,7 +167,7 @@ def _saveUrlCache(url, post_data, data, headers):
only_headers = 1
data = ""
created = time.mktime(time.localtime())
t = (url_hash, domain, url, post_data, simplejson.dumps(headers), created, data, only_headers)
t = (url_hash, domain, url, post_data, simplejson.dumps(headers), created, sqlite3.Binary(data), only_headers)
c.execute(u"""INSERT OR REPLACE INTO cache values (?, ?, ?, ?, ?, ?, ?, ?)""", t)
# Save (commit) the changes and clean up
@ -200,7 +200,7 @@ def migrate_to_db():
fd = open(f + ".headers", "r")
headers = fd.read()
fd.close()
t = (url_hash, domain, url, post_data, headers, created, data, 0)
t = (url_hash, domain, url, post_data, headers, created, sqlite3.Binary(data), 0)
c.execute(u"""INSERT OR REPLACE INTO cache values (?, ?, ?, ?, ?, ?, ?, ?)""", t)
conn.commit()