我把我的torrent信息,从一个bencoded格式的torrent文件(由libtorrent编写)放入sqlite3数据库中的blob中,如下所示:
conn = sqlite3.connect(self.path + '/files/torrents.db')
c = conn.cursor()
q = 'UPDATE torrents SET torrent = ? WHERE name = ?'
c.execute(q, (sqlite3.Binary(data),name))
conn.commit()
conn.close()
但是,如果我使用select查询从数据库中检索blob,我得到的是一个buffer对象。。如何将其转换回我放入数据库的内容,或者更确切地说,转换成sqlite3.Binary文件 我想要我的bencoded bytes对象回来。在
我想出来了。。调用str()方法后得到了需要的缓冲区。在
相关问题 更多 >
编程相关推荐