BookBase

The idea is to make a very simple application that showcases relationships (one-to-many and many-to-many) and a complex UI.

The application will be a single user book database.

Eye Candy

screenshot

Database Structure

3 Tables:

  • book table:
    • book_id integer primary key
    • title varchar(50)
    • author_id integer (a foreign key representing the primary author)
    • editor varchar(20) (not really the editor, it's the publisher, go figure)
    • isbn varchar(20)
    • category varchar(20) (user defined classfication)
    • subcategory varchar(20) (user defined classfication)
    • edition varchar(10)
    • year_pub varchar(4) (year publish in string format)
    • collection varchar(20)
    • language varchar(20) (it's written in what?)
  • author table
    • author_id integer primary key
    • authorname
  • bookauthor
    • bookauthor_id integer primary key
    • book_id integer (guess what it's a foreing key)
    • author_id integer (guess what it's a foreing key)

Available Files

  • makeDB.py - an utility script that creates the SQLite db and a couple of records on each table
  • bookbase.cdxml - the UI (almost complete, done with the Dabo Class Designer)
  • bookbase.py - the main script (as generated by the Dabo Class Designer)
  • cx_bookdb.cnxml - the connection file
  • bookbase-code.py - the code file that goes with the cdxml file
  • bookdb.db - the SQLite db

Dependencies

  • Apart from Dabo ;-) just SQLite & pysqlite (both already included if your running Python 2.5)

What is Missing

Plenty !

  • use of Toolbar? (to add books and authors to the respective active list)
  • the bizcode
  • populating the ListBox? with authors assigned to a book (book_id->bookauthor.book_id) Done
  • translate the UI to English (since it's going to be a demo app)
  • discard the default menu (or change it according to our needs - to be defined)

More will come soon.

Comments by Paul

I unrar'd your files and tried to run on my system, and there were immediately a couple issues:

  1. makeDB.py fails in python 2.5. Change the sqlite import to:
    try:
        from sqlite3 import dbapi2 as sqlite
    except ImportError:
        # prior to python 2.5
        from pysqlite2 import dbapi2 as sqlite
    
  2. the connection file contains an absolute path to the database instead of a relative one. Change the relevant area of cx_bookdb.cnxml to read:
                    <database>./bookbd.db</database>
    
  1. But the main part of your problem is that you never requery the author bizobj. Edit bookbase-code.py and change the the afterInitAll() to read:
    ## *!* ## Dabo Code ID: dForm-top
    def afterInitAll(self):
            self.requery()
            self.requery("author")
    

This is needed because the original requery() only requeries the PrimaryBizobj?.

Hope it helps! --Paul

Comments by Miguel

More than helps. Thank you.

Regarding your comments/help: (I've took the liberty to number your comments)

2. Perhaps it would be a good idea for the connection editor to record relative path's instead of absolute. 3. Ok! Problem solved. Works like a charm.

Txs, Miguel

Attachments