You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importdictdatabaseasDDBfrompath_dictimportPathDictimporttime# Measure time to get all cupst1=time.perf_counter()
cups=DDB.at("cups/*", key="organizer_email").read()
# REMOVE where selector# KEEP as_type since it is also important in session# KEEP at() since it is also used in session# ADD: read_key(key, as_type=None) and read_keys(keys, as_type=None)# ... OR ADD: .select_key(key) and .select_keys(keys) and .select_all() and .select_where(f) as intermediate step before read() or session()# File Alt 1DDB.read_file("cups/aachen", as_type=PathDict)
DDB.read_file("cups/aachen", key="version", as_type=PathDict)
DDB.read_file("cups/aachen", keys=["version", "name"], as_type=PathDict)
DDB.read_file("cups/aachen", not_keys=["big_part"], as_type=PathDict)
withDDB.file_session("cups/aachen", as_type=PathDict) as (session, cup):
cup["count"] +=1session.write(cup)
withDDB.file_session("cups/aachen", key="version", as_type=PathDict) as (session, version):
version+=1session.write(version)
# File Alt 2DDB.at_file("cups/aachen").read(as_type=PathDict)
DDB.at_file("cups/aachen").select_key("version").read(as_type=PathDict)
DDB.at_file("cups/aachen").select_keys("version", "name").read(as_type=PathDict)
DDB.at_file("cups/aachen").select_not_keys("big_part").read(as_type=PathDict)
withDDB.at_file("cups/aachen").session(as_type=PathDict) as (session, cup):
cup["count"] +=1session.write(cup)
# File Alt 3DDB.file.at("cups/aachen").read(as_type=PathDict)
DDB.file.at("cups/aachen").select_key("version").read(as_type=PathDict)
DDB.file.at("cups/aachen").select_keys("version", "name").read(as_type=PathDict)
DDB.file.at("cups/aachen").select_not_keys("big_part").read(as_type=PathDict)
withDDB.file.at("cups/aachen").session(as_type=PathDict) as (session, cup):
cup["count"] +=1session.write(cup)
# Dir Alt 1DDB.read_dir("cups", as_type=PathDict)
DDB.read_dir("cups", key="version", as_type=PathDict)
DDB.read_dir("cups", keys=["version", "name"], as_type=PathDict)
withDDB.dir_session("cups", as_type=PathDict) as (session, cups):
cups["aachen"]["count"] +=1session.write(cups)
withDDB.dir_session("cups", key="version", as_type=PathDict) as (session, versions):
versions["aachen", "version"] +=1session.write(versions)
# Dir Alt 2DDB.at_dir("cups").read(as_type=PathDict)
DDB.at_dir("cups").select_key("version").read(as_type=PathDict)
DDB.at_dir("cups").select_keys("version", "name").read(as_type=PathDict)
withDDB.at_dir("cups").session(as_type=PathDict) as (session, cups):
cups["aachen"]["count"] +=1session.write(cups)
withDDB.at_dir("cups").select_key("version").session(as_type=PathDict) as (session, versions):
versions["aachen", "version"] +=1session.write(versions)
# Dir Alt 3DDB.dir.at("cups").read(as_type=PathDict)
DDB.dir.at("cups").select_key("version").read(as_type=PathDict)
DDB.dir.at("cups").select_keys("version", "name").read(as_type=PathDict)
withDDB.dir.at("cups").session(as_type=PathDict) as (session, cups):
cups["aachen"]["count"] +=1session.write(cups)
withDDB.dir.at("cups").select_key("version").session(as_type=PathDict) as (session, versions):
versions["aachen", "version"] +=1session.write(versions)
# Read key from top level file:v1=DDB.at("app_state", key="version").read(as_type=PathDict)
v2=DDB.at(file="app_state").select_key("version").read(as_type=PathDict)
# Read one cup:v1=DDB.at("cups/1").read(as_type=PathDict)
v2=DDB.at("cups/1").read(as_type=PathDict)
# Read all cups:v1=DDB.at("cups/*").read(as_type=PathDict)
v2=DDB.at("cups").read(as_type=PathDict)
v3=DDB.at(dir="cups").select_all().read(as_type=PathDict)
# Read only mail addresses:v1=DDB.at("cups/*", key="organizer_email").read(as_type=PathDict)
v2=DDB.at("cups/*").select_key("organizer_email").read(as_type=PathDict)
# Read locations and emails:v1= ... # Not Possiblev2=DDB.at("cups/*").select_keys("organizer_email", "location").read(as_type=PathDict)
t2=time.perf_counter()
assertlen(cups) ==228print(f"Time to get all cups: {(t2-t1)*1000:.1f} ms")
print(cups) ```
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: