liveBook · Manning

Data storage

As explained in A Pythonic Adventure: From Python basics to a working web app

Data storage is the retention of program data so that it can be retrieved after or beyond the current execution.

Data storage keeps an application’s information available beyond its current run. In the order program, confirmed orders are stored in an orders.json file, turning a menu script into a useful real application. section 9.1 section 9.0

A simple file-storage pattern:

  • Check whether the storage file exists with os.path.exists(). section 9.1
  • Load existing orders from JSON, or begin with an empty list when the file is missing. section 9.0
  • Append each confirmed order and save the complete list back to the file. section 9.0

An order survives the program

After an order from Jason is entered, the program saves it in orders.json. Opening the file reveals the recent order alongside earlier orders. section 9.0

orders = load_orders("orders.json")
main_menu(orders)
save_orders(orders, "orders.json")

See the compact integration point: load orders before the menu, then save them after the menu finishes. section 9.0

How A Pythonic Adventure: From Python basics to a working web app covers it

How deep it goes
Explains file existence checks, JSON loading and saving, missing-file fallback, and menu integration.
Examples
Uses orders.json, JSON order lists, os.path.exists(), and load_orders and save_orders functions.
What it assumes
Builds on an order-collecting program and introduces storage alongside input and output, data structures, algorithms, and error checking.
What you can do after
Operate a file-backed order program by loading existing orders, appending confirmed orders, and saving them.
How it connects
Connects data storage with JSON files, data structures, algorithms, input and output, and error checking.

Also explained in

Compare how 2 books explain data storage →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of A Pythonic Adventure: From Python basics to a working web app. The section links point to the parts of the book it draws on.