Section 21.5. Exercises


21.5. Exercises

21-1.

Database API. What is the Python DB-API? Is it a good thing? Why (or why not)?

21-2.

Database API. Describe the differences between the database module parameter styles (see the paramstyle module attribute).

21-3.

Cursor Objects. What are the differences between the cursor execute*() methods?

21-4.

Cursor Objects. What are the differences between the cursor fetch*() methods?

21-5.

Database Adapters. Research your RDBMS and its Python module. Is it DB-API compliant? What additional features are available for that module that are extras not required by the API?

21-6.

Type Objects. Study using Type objects for your database and DB-API adapter and write a small script that uses at least one of those objects.

21-7.

Refactoring. In the create() function of Example 21.1 (ushuffle_db.py), a table that already exists is dropped and re-created by recursively calling create() again. This is dangerous in case the re-creation of the table fails (again) because you will then have infinite recursion. Fix this problem by creating a more practical solution that does not involve copying the create query (cur.execute()) again in the exception handler. Extra Credit: Try to recreate the table a maximum of three times before returning failure back to the caller.

21-8.

Database and HTML. Take any existing database table, and use the knowledge you developed from Chapter 20 and output the contents of a database table into an HTML table.

21-9.

Web Programming and Databases. Take our "user shuffle" example (ushuffle_db.py), and create a Web interface for it.

21-10.

GUI Programming and Databases. Take our "user shuffle" example (ushuffle_db.py), and throw a GUI for it.

21-11.

Stock Portfolio Class. Update the stock database example from Chapter 13 to use a relational database.

21-12.

Switching ORMs to a Different RDBMS. Take either the SQLAlchemy (ushuffle_sa.py) or SQLObject (ushuffle_so.py) application and swap out MySQL as the back-end RDBMS for another one of your choice.



Core Python Programming
Core Python Programming (2nd Edition)
ISBN: 0132269937
EAN: 2147483647
Year: 2004
Pages: 334
Authors: Wesley J Chun

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net