Database
DatabaseConfig
Bases: PrettyModel
Source code in passengersim/config/database.py
commit_count_delay
class-attribute
instance-attribute
Commit transactions to the database will only be honored this frequently.
By setting this number greater than 1, the transaction frequency will be reduced, improving overall runtime performance by storing more data in RAM and writing to persistent storage less frequently.
dcp_write_hooks
class-attribute
instance-attribute
Additional callable functions that write to the database at each DCP.
Each should have a signature matching f(db, sim, dcp)
.
engine
class-attribute
instance-attribute
Database engine to use.
Currently only sqlite
is fully implemented.
fast
class-attribute
instance-attribute
Whether to use pre-compiled SQL write instructions.
filename
class-attribute
instance-attribute
Name of file for SQLite output.
pragmas
class-attribute
instance-attribute
A list of PRAGMA commands to execute upon opening a database connection.
store_leg_bid_prices
class-attribute
instance-attribute
Should leg bid prices be stored in the database.
write_items
class-attribute
instance-attribute
write_items: set[
Literal[
"leg",
"bucket",
"fare",
"demand",
"leg_daily",
"leg_final",
"bucket_final",
"fare_final",
"demand_final",
"bookings",
"pathclass",
"pathclass_daily",
"pathclass_final",
]
] = {"leg_final", "fare_final", "demand_final", "bookings"}
Which items should be written to the database.
The following values can be provided in this set:
- leg: write every leg to the
leg_detail
table at every DCP. - leg_final: write every leg to the
leg_detail
table only at DCP 0. - bucket: write every leg bucket to the
leg_bucket_detail
table at every DCP. - bucket_final: write every leg bucket to the
leg_bucket_detail
table only at DCP 0. - fare: write every fare to the
fare_detail
table at every DCP. - fare_final: write every fare to the
fare_detail
table only at DCP 0. - demand: write every demand to the
demand_detail
table at every DCP. - bookings: store booking summary data at every DCP and write an aggregate
summary of bookings by DCP to the
bookings_by_timeframe
table at the end of the simulation.