Databases and Persistence

Devcult - 6G and Satellites
1 min readJul 3, 2019

--

Persistent data is the kind of data that outlives a program that creates it.
How to save information in between program executions?
1. Flat files: Text and bytes stored directly in the computer.
2. DBM keyed files: Keyed access to strings stored in dictionary-like files
3. Pickled objects: Serialized Python objects saved to files and streams
4. Shelve files: Pickled Python objects saved in DBM keyed files.
5. Object-oriented databases(OODBs): Persistent Python objects stored in persistent dictionaries(ZODB, Durus)
6. SQL relational databases(RDBMSs): Table-based storage that supports SQL queries(SQLite, MySQL, PostGreSQL etc)
7. Object relational mappers(ORMs): Mediators that map Python classes to relational tables(SQLObject, SQLAlchemy)

Flat files

Flat files are handy for simple persistence tasks, but they are generally geared toward a sequential processing mode.

Although it is possible to jump around to arbitrary locations with ‘seek’ calls, flat files don’t provide much structure to data beyond the notion of bytes and text lines.

DBM files

  1. Information can be stored in a DBM file using unique key.(Technically DBM files generally use a technique called hashing to store data in files)
  2. DBM is one of the easiest ways to save information in Python since they behave so much like in-memory dictionaries.
  3. In a DBM file object, indexing by key fetches data from the file. Assigning to an index stores data in the file.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Devcult - 6G and Satellites
Devcult - 6G and Satellites

No responses yet

Write a response