Home > Articles > Open Source > Python

Databases, GUIs, and Python

  • Print
  • + Share This
Now that Python has grown up, it has to hold its own in two- and three-tier database applications against corporate heavyweights such as Java and Visual Basic. Boudewijn Rempt analyzes Python's possibilities and weighs its strengths and weaknesses.
Like this article? We recommend

Like this article? We recommend

Any application that exhibits any complexity contains something that could be called a database: structured data that is persisted between invocations of the application. Uses range from the dedicated object databases that constitute a word-processor document, to the vanilla tables and files of a payroll application. However, when people talk about database-based applications, they mostly think of a basic two- or three-tier architecture: a relational database, a GUI front end, and perhaps a middle layers.

Now that Python has grown up, it has to hold its own in this area against corporate heavyweights such as Java, Visual Basic, or any of the proprietary solutions such as Oracle Forms. This article examines the possibilities, strengths, and weaknesses of Python in the area of two- and three-tier database applications.

Files

The simplest way to store your data is to use key-value pairs. Python's native dictionary type makes this possible. Using one of the standard modules, such as pickle, shelve, or anydbm, you can store your data in a platform-independent file format.

It is quite easy to create a simple file-based database with multiple indexes using only Python dictionaries and pickle. If the needs of your GUI or Web application are simple—that is, if you don't need many dynamically built queries over many tables—you can use such a back end instead of a real database. An example is the textdb back end for the dbobj database wrapper model I have developed.

  • + Share This
  • 🔖 Save To Your Account