Chapter 3
Tutorial

3.1 Connecting to a database


PIC

Figure 3.1: Get Connection String Dialog box



PIC

Figure 3.2: Get Connection String Dialog box, with connection string filled in


The Home Librarian uses a database “back end” to store the card records. It is possible to use one of several different database systems, including PostgreSQL, MySQL, Sqlite, SQL Server, and others. All you need is a ODBC driver library installed. The Home Librarian attempts to connect to a database on startup. It reads in one of a set of configuration files for a connection string. If it does not find either the configuration files or if there isn’t a valid connection string in these files, it will prompt for a connection string using a “Get Connection String Dialog” (described in Section 2.5.1). A typical “Get Connection String Dialog” box is shown in Figure 3.1. In Figure 3.2 is a “Get Connection String Dialog” with a connection string filled in. Selecting “OK” will connect to the database.


PIC

Figure 3.3: (Re-)Create the database question box


When you connect to a new database or a database never before used with the Home Librarian program, a dialog box prompting confirmation to (re-)create the database is displayed, as shown in Figure 3.3.


PIC

Figure 3.4: Amazon search results for 1-56592-183-6



PIC

Figure 3.5: Entering a new key



PIC

Figure 3.6: Initialized card for Java in a Nutshell



PIC

Figure 3.7: edited card for Java in a Nutshell


Once connected to a database, it is now possible to add cards to the database, using the “Update Library” function. One way to add cards is to search on Amazon for information about items in your library. For example if the book “Java in a Nutshell” with ISBN number 1-56592-183-6, you can perform the search shown in Figure 3.4. We can now hightlight the search result and create a card from it. We are prompted for a new key to uniquely identify this item, as shown in Figure 3.5. We now have a new card record with most of its fields filled out from the Amazon data, shown in Figure 3.6. After a bit of editing, the card editor looks like Figure ??. The Subject, Location, and Category fields have been filled in. The Descriptive text has been trimmed, and a collection of keywords added.

We can now save this card in the database by clicking on the “Save” button. We now have a database with this card in it. We can now perform some searches using the search screen.


PIC

Figure 3.8: Searching for keyword “java”



PIC

Figure 3.9: More information about Java-Flanagan-1


A card database can be searched in several ways. Figure 3.8 shows a search by keyword using the keyword “java”. And Figure 3.9 shows what is displayed when the search result is highlighted and the “Display More Information” button is clicked.