Exemplo n.º 1
0
def main():
    db = Database("/tmp/demo_secure")
    key = "abcdefgh"
    id_ind = EncUniqueHashIndex(db.path, "id")
    db.set_indexes([id_ind])
    db.create()
    db.id_ind.enc_key = key
    print(db.id_ind.storage)

    for x in xrange(100):
        db.insert(dict(x=x, data="testing"))

    db.close()
    dbr = Database("/tmp/demo_secure")
    dbr.open()
    dbr.id_ind.enc_key = key

    for curr in dbr.all("id", limit=5):
        print(curr)
Exemplo n.º 2
0
def migrate(source, destination):
    """
    Very basic for now
    """
    dbs = Database(source)
    dbt = Database(destination)
    dbs.open()
    dbt.create()
    dbt.close()
    for curr in os.listdir(os.path.join(dbs.path, "_indexes")):
        if curr != "00id.py":
            shutil.copyfile(
                os.path.join(dbs.path, "_indexes", curr),
                os.path.join(dbt.path, "_indexes", curr),
            )
    dbt.open()
    for c in dbs.all("id"):
        del c["_rev"]
        dbt.insert(c)
    return True