Python, Files, and Databases
What’s a Database?
A database is an organized collection of data 1. Data is stored on disk and in memory in a manner that maximizes reading data in complex ways.
Why a Database?
Databases are extremely good at complex queries. They also excel at managing concurrency, data integrity and redundancy.
Why Not a Database?
Storing data on a file (referred to as a flat file) is fine. In fact in some situations, storing data in a flat file is better that using a database. In others it’s worse. Flat files shouldn’t be considered verboten but rather just another tool in your tool chest. You wouldn’t use a hammer to tighten a bolt, would you?
Let’s look at a couple examples:
Volker is writing a program that interacts with hardware via a serial port. He wants to be able to configure the port and communication settings without having to change his program.
This is a great
Continue reading →