저는 ZODB를 사용하고 있습니다. 'database_1.fs'
파일을 다른 'database_2.fs'
, 에 복사하려고 했으므로 그 'database_1.fs'
의 루트 사전을 열었습니다. 텍스트 파일에이 파일 (pickle.dump
)을 열었습니다.ZODB에서 절을 뽑았지만 크기가 작습니다.
그럼 내가 사전 변수에 'database_2.fs'
의 루트 사전을 업데이트합니다.
그것은 작동하지만, 왜 'database_1.fs'
의 크기가 다른 'database_2.fs'
의 크기와 같지 않은지 궁금합니다.
그들은 여전히 서로의 사본입니다.
def openstorage(store): #opens the database
data={}
data['file']=filestorage
data['db']=DB(data['file'])
data['conn']=data['db'].open()
data['root']=data['conn'].root()
return data
def getroot(dicty):
return dicty['root']
def closestorage(dicty): #close the database after Saving
transaction.commit()
dicty['file'].close()
dicty['db'].close()
dicty['conn'].close()
transaction.get().abort()
는 그 내가 할 수있는 작업은 다음과 같습니다 -
import pickle
loc1='G:\\database_1.fs'
op1=openstorage(loc1)
root1=getroot(op1)
loc2='G:database_2.fs'
op2=openstorage(loc2)
root2=getroot(op2)
>>> len(root1)
215
>>> len(root2)
0
pickle.dump(root1, open("save.txt", "wb"))
item=pickle.load(open("save.txt", "rb")) #now item is a dictionary
root2.update(item)
closestorage(op1)
closestorage(op2)
#after I open both of the databases
#I get the same keys in both databases
#But `database_2.fs` is smaller that `database_2.fs` in size I mean.
>>> len(root2)==len(root1)==215 #they have the same keys
True
참고 :
(1) 지속적인 사전 및 목록은 원래 database_1.fs
(2) 모두 그들에있다 동일한 길이와 동일한 색인을가집니다.
ZODB는 영구 트랜잭션 로그 인 AFAIR을 저장합니다. –
당신은 로그 파일이 여분의 크기를 차지한다는 것을 의미합니까 ?? –