Using Python’s Built-In Database with sqlite3

Intuitive Python — by David Muller (19 / 41)

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 Calling Other Programs with subprocess | TOC | Profiling Python Code with cProfile 👉

A fully featured SQL database called SQLite comes bundled with your Python programming language install. In case you haven’t used SQLite before, it’s a SQL database engine that stores all your table and row data in a single file. SQLite pervades software today: it comes with every Android and iOS phone, all the major web browsers, inside PHP, all Macs, and so forth.[58]

You can use Python’s sqlite3 standard library module to create a SQLite database, connect to it, and write and read contents from it.

What Does SQLite Do Well?

NOTE

SQLite pervades software for good reason: its backing file format is fully backward compatible and cross platform, and SQLite is an exceptionally well-tested application. If you give someone a SQLite file, they will be able to open it and seek through its contents efficiently (no matter how big they might be). SQLite — effectively — gives you a file that you can write to transactionally without worrying about concurrency bugs, operating system idiosyncrasies, network latency, power failures, or data corruption. You might want to use SQLite if you have a large amount of row-based data to store, need several distinct processes to cooperatively and simultaneously read and write to a single file…

--

--

The Pragmatic Programmers
The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.